Skip to content

Commit

Permalink
Merge pull request #57 from CAVEconnectome/trivial_change
Browse files Browse the repository at this point in the history
added blank line
  • Loading branch information
fcollman authored Dec 7, 2024
2 parents cb99cca + 53773c0 commit 453de19
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/annotationengine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- "tests/**"
pull_request:
branches: [master]
workflow_dispatch:

jobs:
test:
Expand All @@ -35,7 +36,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') }}
Expand Down Expand Up @@ -70,4 +71,4 @@ jobs:
- name: Upload coverage to codecov
uses: codecov/codecov-action@v5
with:
use_oidc: true
token: {{ secrets.CODECOV_TOKEN }}
68 changes: 28 additions & 40 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

aligned_volume_name = "test_aligned_volume"


class TestHealthEndpoint:
def test_health_endpoint(self, client):
url = "annotation/api/versions"
Expand Down Expand Up @@ -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 = {
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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"
)
Expand All @@ -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 = {
Expand All @@ -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

Expand All @@ -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": [
Expand All @@ -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),
Expand All @@ -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])
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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]

0 comments on commit 453de19

Please sign in to comment.