From b4462bc30c2c50f50c9cb01cbba9ea7e9bc66ed1 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sat, 7 Dec 2024 11:59:38 -0800 Subject: [PATCH 1/4] added blank line --- test/test_api.py | 68 ++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/test/test_api.py b/test/test_api.py index f2f6876..de03d2e 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -8,6 +8,7 @@ aligned_volume_name = "test_aligned_volume" + class TestHealthEndpoint: def test_health_endpoint(self, client): url = "annotation/api/versions" @@ -47,12 +48,12 @@ def test_post_table(self, client): assert response.json is None def test_put_table(self, client, modify_g): - ''' + """ 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. - ''' - + """ + # Alter the description and populate the notice_text logging.info("TEST") data = { @@ -77,9 +78,9 @@ def test_put_table(self, client, modify_g): follow_redirects=True, ) logging.info(response) - assert response.json['description'] == "Altered test description" - assert response.json['notice_text'] == "Notice" - + assert response.json["description"] == "Altered test description" + assert response.json["notice_text"] == "Notice" + # ================================================================================ # Test that notice_text is erased logging.info("TEST") @@ -103,7 +104,7 @@ def test_put_table(self, client, modify_g): follow_redirects=True, ) logging.info(response) - assert response.json['notice_text'] is None + assert response.json["notice_text"] is None # ================================================================================ # Repopulate notice_text @@ -128,8 +129,8 @@ def test_put_table(self, client, modify_g): follow_redirects=True, ) logging.info(response) - assert response.json['notice_text'] == "Notice2" - + assert response.json["notice_text"] == "Notice2" + # ================================================================================ # Test that notice_text is erased logging.info("TEST") @@ -153,7 +154,7 @@ def test_put_table(self, client, modify_g): follow_redirects=True, ) logging.info(response) - assert response.json['notice_text'] is None + assert response.json["notice_text"] is None def test_post_table_to_be_deleted(self, client): logging.info(client) @@ -191,17 +192,15 @@ def test_get_tables(self, client): ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name response = client.get( - url, content_type="application/json", - follow_redirects=False + url, content_type="application/json", follow_redirects=False ) logging.info(response) - + assert response.json == ["test_table", "test_table_to_delete"] class TestAnnotationTableEndpoints: def test_get_table_metadata(self, client): - url = ( f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table" ) @@ -211,9 +210,7 @@ def test_get_table_metadata(self, client): ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name - response = client.get(url, - follow_redirects=False - ) + response = client.get(url, follow_redirects=False) logging.info(response.json) metadata = { @@ -234,22 +231,19 @@ def test_get_table_metadata(self, client): "write_permission": "PRIVATE", } response_json = response.json - del response_json['created'] - del response_json['last_modified'] + del response_json["created"] + del response_json["last_modified"] assert response_json == metadata def test_mark_table_to_delete(self, client, modify_g): - url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table_to_delete" - + with mock.patch( "annotationengine.api.check_aligned_volume" ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name - response = client.delete(url, - follow_redirects=False - ) + response = client.delete(url, follow_redirects=False) logging.info(response.json) assert response.json is True @@ -261,16 +255,13 @@ def test_get_row_count(self, client): "annotationengine.api.check_aligned_volume" ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name - response = client.get(url, - follow_redirects=False - ) + response = client.get(url, follow_redirects=False) logging.info(response.json) assert response.json == 0 class TestAnnotationsEndpoints: def test_post_annotations(self, client, modify_g): - url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table/annotations" data = { "annotations": [ @@ -294,7 +285,7 @@ def test_post_annotations(self, client, modify_g): "annotationengine.api.trigger_supervoxel_lookup", ) as mock_trigger_supervoxel_lookup: mock_trigger_supervoxel_lookup.return_value = None - + response = client.post( url, data=json.dumps(data), @@ -311,9 +302,7 @@ def test_get_annotations(self, client): "annotationengine.api.check_aligned_volume" ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name - response = client.get(url, query_string=data, - follow_redirects=False - ) + response = client.get(url, query_string=data, follow_redirects=False) logging.info(response) logging.info(response.json) logging.info(response.json[0]) @@ -323,7 +312,7 @@ def test_get_annotations(self, client): assert response.json[0]["post_pt_position"] == [33, 33, 0] assert response.json[0]["valid"] == True assert response.json[0]["superceded_id"] == None - assert response.json[0]["deleted"] == 'None' + assert response.json[0]["deleted"] == "None" def test_update_annotations(self, client): url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table/annotations" @@ -346,11 +335,11 @@ def test_update_annotations(self, client): "annotationengine.api.trigger_supervoxel_lookup", ) as mock_trigger_supervoxel_lookup: mock_trigger_supervoxel_lookup.return_value = None - response = client.put(url, data=json.dumps(data), - follow_redirects=False - ) + response = client.put( + url, data=json.dumps(data), follow_redirects=False + ) logging.info(response) - assert response.json == {'1': 2} + assert response.json == {"1": 2} def test_delete_annotations(self, client): url = f"/annotation/api/v2/aligned_volume/{aligned_volume_name}/table/test_table/annotations" @@ -360,8 +349,7 @@ def test_delete_annotations(self, client): "annotationengine.api.check_aligned_volume" ) as mock_aligned_volumes: mock_aligned_volumes.return_value = aligned_volume_name - response = client.delete(url, data=json.dumps(data), - follow_redirects=False - ) + response = client.delete(url, data=json.dumps(data), follow_redirects=False) logging.info(response) + assert response.json == [2] From e545493a923be27588262d3bcb610255aa505b28 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sat, 7 Dec 2024 12:01:46 -0800 Subject: [PATCH 2/4] updating cache action --- .github/workflows/annotationengine.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/annotationengine.yml b/.github/workflows/annotationengine.yml index 20452fc..7203509 100644 --- a/.github/workflows/annotationengine.yml +++ b/.github/workflows/annotationengine.yml @@ -35,7 +35,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.9 - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/test_requirements.txt') }} From f41ea76bac41142ed11e81abd9b0b21b27f26699 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sat, 7 Dec 2024 12:06:20 -0800 Subject: [PATCH 3/4] trying to fix coverage --- .github/workflows/annotationengine.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/annotationengine.yml b/.github/workflows/annotationengine.yml index 7203509..bb163fa 100644 --- a/.github/workflows/annotationengine.yml +++ b/.github/workflows/annotationengine.yml @@ -70,4 +70,4 @@ jobs: - name: Upload coverage to codecov uses: codecov/codecov-action@v5 with: - use_oidc: true \ No newline at end of file + token: {{ secrets.CODECOV_TOKEN }} \ No newline at end of file From 53773c02a5e38862151788661228910c584886e5 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sat, 7 Dec 2024 12:09:09 -0800 Subject: [PATCH 4/4] adding manual trigger --- .github/workflows/annotationengine.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/annotationengine.yml b/.github/workflows/annotationengine.yml index bb163fa..fb4af54 100644 --- a/.github/workflows/annotationengine.yml +++ b/.github/workflows/annotationengine.yml @@ -13,6 +13,7 @@ on: - "tests/**" pull_request: branches: [master] + workflow_dispatch: jobs: test: