diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/auth/test_migration_init_data_in_resource_categories_table.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/auth/test_migration_init_data_in_resource_categories_table.py b/tests/unit/auth/test_migration_init_data_in_resource_categories_table.py index 4b5a039..59ef385 100644 --- a/tests/unit/auth/test_migration_init_data_in_resource_categories_table.py +++ b/tests/unit/auth/test_migration_init_data_in_resource_categories_table.py @@ -24,5 +24,29 @@ def test_apply_init_data(auth_testdb_path, auth_migrations_dir, backend): cursor.execute("SELECT * FROM resource_categories") results = cursor.fetchall() assert len(results) == 3, "Expected 3 rows of data." + assert sorted(results) == sorted(( + ('fad071a3-2fc8-40b8-992b-cdefe7dcac79', 'mrna', 'mRNA Dataset'), + ('548d684b-d4d1-46fb-a6d3-51a56b7da1b3', 'phenotype', + 'Phenotype (Publish) Dataset'), + ('48056f84-a2a6-41ac-8319-0e1e212cba2a', 'genotype', + 'Genotype Dataset'))) rollback_migrations(backend, older_migrations + [the_migration]) + +@pytest.mark.unit_test +def test_rollback_init_data(auth_testdb_path, auth_migrations_dir, backend): + older_migrations = migrations_up_to(migration_path, auth_migrations_dir) + the_migration = get_migration(migration_path) + apply_migrations(backend, older_migrations) + with closing(sqlite3.connect(auth_testdb_path)) as conn, closing(conn.cursor()) as cursor: + cursor.execute("SELECT * FROM resource_categories") + assert len(cursor.fetchall()) == 0, "Expected empty table." + apply_single_migration(auth_testdb_path, the_migration) + cursor.execute("SELECT * FROM resource_categories") + results = cursor.fetchall() + assert len(results) == 3, "Expected 3 rows of data." + rollback_single_migration(auth_testdb_path, the_migration) + cursor.execute("SELECT * FROM resource_categories") + assert len(cursor.fetchall()) == 0, "Expected empty table." + + rollback_migrations(backend, older_migrations) |