From d6a4d13a5043b1f2fe386b80545be882087b06b6 Mon Sep 17 00:00:00 2001 From: Keith Wiley Date: Thu, 12 Dec 2024 09:33:43 -0800 Subject: [PATCH 1/3] Removed modify_g fixture --- test/conftest.py | 7 ------- test/test_api.py | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 75a00cd..b3da2b7 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -76,13 +76,6 @@ def app_config(client): yield client.application -@pytest.fixture() -def modify_g(client): - g.auth_user = {"id": 1} - g.user = "test" - g.id = 1 - - @pytest.fixture() def mock_info_service(): aligned_volume_url = os.path.join(INFOSERVICE_ENDPOINT, "api/aligned_volumes") diff --git a/test/test_api.py b/test/test_api.py index f2f6876..3632071 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -23,7 +23,7 @@ def test_post_table(self, client): "table_name": "test_table", "schema_type": "synapse", "metadata": { - "user_id": "1", + "user_id": "0", "description": "Test description", "flat_segmentation_source": "precomputed://gs://my_cloud_bucket/image", "voxel_resolution_x": 4, @@ -46,7 +46,7 @@ def test_post_table(self, client): logging.info(response) assert response.json is None - def test_put_table(self, client, modify_g): + def test_put_table(self, client): ''' These tests have to be run in sequential order, so instead of trusting the testing framework to run independent tests in the intended order, @@ -58,7 +58,7 @@ def test_put_table(self, client, modify_g): data = { "table_name": "test_table", "metadata": { - "user_id": "1", + "user_id": "0", "description": "Altered test description", "flat_segmentation_source": "precomputed://gs://my_cloud_bucket/image", "notice_text": "Notice", @@ -86,7 +86,7 @@ def test_put_table(self, client, modify_g): data = { "table_name": "test_table", "metadata": { - "user_id": "1", + "user_id": "0", "notice_text": "", }, } @@ -111,7 +111,7 @@ def test_put_table(self, client, modify_g): data = { "table_name": "test_table", "metadata": { - "user_id": "1", + "user_id": "0", "notice_text": "Notice2", }, } @@ -136,7 +136,7 @@ def test_put_table(self, client, modify_g): data = { "table_name": "test_table", "metadata": { - "user_id": "1", + "user_id": "0", "notice_text": "", }, } @@ -161,7 +161,7 @@ def test_post_table_to_be_deleted(self, client): "table_name": "test_table_to_delete", "schema_type": "synapse", "metadata": { - "user_id": "1", + "user_id": "0", "description": "Test description", "flat_segmentation_source": "precomputed://gs://my_cloud_bucket/image", "voxel_resolution_x": 4, @@ -225,7 +225,7 @@ def test_get_table_metadata(self, client): "voxel_resolution_y": 4.0, "valid": True, "schema_type": "synapse", - "user_id": "1", + "user_id": "0", "notice_text": None, "reference_table": None, "voxel_resolution_x": 4.0, @@ -238,7 +238,7 @@ def test_get_table_metadata(self, client): del response_json['last_modified'] assert response_json == metadata - def test_mark_table_to_delete(self, client, modify_g): + def test_mark_table_to_delete(self, client): url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table_to_delete" @@ -269,7 +269,7 @@ def test_get_row_count(self, client): class TestAnnotationsEndpoints: - def test_post_annotations(self, client, modify_g): + def test_post_annotations(self, client): url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table/annotations" data = { From 7a6a5162a4551aaa9c93fd95f11cb64152d77c0e Mon Sep 17 00:00:00 2001 From: Keith Wiley Date: Thu, 12 Dec 2024 09:42:37 -0800 Subject: [PATCH 2/3] Update test_api.py --- test/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_api.py b/test/test_api.py index 27e3f34..da5e453 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -48,6 +48,7 @@ def test_post_table(self, client): assert response.json is None def test_put_table(self, client): + """ These tests have to be run in sequential order, so instead of trusting the testing framework to run independent tests in the intended order, simply package them into a single function. From bb7484a0e58d963268ac68be589ef9fd79f836e2 Mon Sep 17 00:00:00 2001 From: Keith Wiley Date: Thu, 12 Dec 2024 11:20:32 -0800 Subject: [PATCH 3/3] Split apart distinct tests --- test/test_api.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/test_api.py b/test/test_api.py index da5e453..8bb565f 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -47,13 +47,7 @@ def test_post_table(self, client): logging.info(response) assert response.json is None - def test_put_table(self, client): - """ - These tests have to be run in sequential order, so instead of trusting - the testing framework to run independent tests in the intended order, - simply package them into a single function. - """ - + def test_put_table1(self, client): # Alter the description and populate the notice_text logging.info("TEST") data = { @@ -81,6 +75,7 @@ def test_put_table(self, client): assert response.json["description"] == "Altered test description" assert response.json["notice_text"] == "Notice" + def test_put_table2(self, client): # ================================================================================ # Test that notice_text is erased logging.info("TEST") @@ -106,6 +101,7 @@ def test_put_table(self, client): logging.info(response) assert response.json["notice_text"] is None + def test_put_table3(self, client): # ================================================================================ # Repopulate notice_text logging.info("TEST") @@ -131,6 +127,7 @@ def test_put_table(self, client): logging.info(response) assert response.json["notice_text"] == "Notice2" + def test_put_table4(self, client): # ================================================================================ # Test that notice_text is erased logging.info("TEST")