diff options
author | Frederick Muriuki Muriithi | 2022-11-03 13:29:28 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-03 13:29:28 +0300 |
commit | fbc8d034a9a034aa37cc3bc3893b4c1344bd09ee (patch) | |
tree | d4cea54555e2637b13111f67c4b3b891b0359176 | |
parent | ef70ddc1fb2800e340de50bcdb3cef2d34cc3b11 (diff) | |
download | genenetwork3-fbc8d034a9a034aa37cc3bc3893b4c1344bd09ee.tar.gz |
Rename migration test.
-rw-r--r-- | tests/unit/auth/test_migration_create_users_table.py (renamed from tests/unit/auth/test_init_database.py) | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/unit/auth/test_init_database.py b/tests/unit/auth/test_migration_create_users_table.py index bf1ed1d..c97c050 100644 --- a/tests/unit/auth/test_init_database.py +++ b/tests/unit/auth/test_migration_create_users_table.py @@ -11,19 +11,29 @@ from tests.unit.conftest import ( migration_path = "migrations/auth/20221103_01_js9ub-initialise-the-auth-entic-oris-ation-database.py" @pytest.mark.unit_test -def test_initialise_the_database(auth_testdb): - with closing(sqlite3.connect(auth_testdb)) as conn, closing(conn.cursor()) as cursor: +def test_create_users_table(auth_testdb_path): + """ + GIVEN: A database migration script to create the `users` table + WHEN: The migration is applied + THEN: Ensure that the table is created + """ + with closing(sqlite3.connect(auth_testdb_path)) as conn, closing(conn.cursor()) as cursor: cursor.execute("SELECT name FROM sqlite_schema WHERE type='table'") result = cursor.fetchall() assert "users" not in [row[0] for row in cursor.fetchall()] - apply_single_migration(auth_testdb, get_migration(migration_path)) + apply_single_migration(auth_testdb_path, get_migration(migration_path)) cursor.execute("SELECT name FROM sqlite_schema WHERE type='table'") assert "users" in [row[0] for row in cursor.fetchall()] @pytest.mark.unit_test -def test_rollback_initialise_the_database(auth_testdb): - with closing(sqlite3.connect(auth_testdb)) as conn, closing(conn.cursor()) as cursor: - apply_single_migration(auth_testdb, get_migration(migration_path)) - rollback_single_migration(auth_testdb, get_migration(migration_path)) +def test_rollback_create_users_table(auth_testdb_path): + """ + GIVEN: A database migration script to create the `users` table + WHEN: The migration is rolled back + THEN: Ensure that the `users` table no longer exists + """ + with closing(sqlite3.connect(auth_testdb_path)) as conn, closing(conn.cursor()) as cursor: + apply_single_migration(auth_testdb_path, get_migration(migration_path)) + rollback_single_migration(auth_testdb_path, get_migration(migration_path)) cursor.execute("SELECT name FROM sqlite_schema WHERE type='table'") assert "users" not in [row[0] for row in cursor.fetchall()] |