Skip to content

Commit

Permalink
Fix some "expected fail" tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Oct 6, 2024
1 parent 0720314 commit eeda99e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
12 changes: 9 additions & 3 deletions validation_service_api/validation_service/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,16 +896,22 @@ class ValidationTest(BaseModel):
# todo: add "publication" field

@classmethod
def from_kg_query(cls, item, client):
def from_kg_query(cls, item, user_client, service_client):
item.pop("@context", None)
item["id"] = client.uuid_from_uri(item["uri"])
item["id"] = user_client.uuid_from_uri(item["uri"])
space = item["project_id"] # what the query calls "project_id" is really the space
item["private"] = is_private(space)
item["project_id"] = project_id_from_space(space)
item["instances"] = [
ValidationTestInstance.from_kg_query(instance, client)
ValidationTestInstance.from_kg_query(instance, user_client)
for instance in item.get("instances", [])
]
if len(item["instances"]) == 0:
item["implementation_status"] = ImplementationStatus.proposal
elif service_client.is_released(item["uri"]):
item["implementation_status"] = ImplementationStatus.published
else:
item["implementation_status"] = ImplementationStatus.dev
data_locations = []
for loc in item["data_location"]:
for field in ("IRI", "URL", "name"):
Expand Down
6 changes: 4 additions & 2 deletions validation_service_api/validation_service/resources/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def query_tests(
if alias:
filters["alias"] = alias
if implementation_status:
# todo: this doesn't work, and requires checking release status,
# hence this filter needs to be applied to the results of the query
filters["implementation_status"] = implementation_status
if project_id:
filters["space"] = [f"collab-{collab_id}" for collab_id in project_id]
Expand Down Expand Up @@ -235,7 +237,7 @@ def query_tests(
).data

return [
cls.from_kg_query(instance, kg_user_client)
cls.from_kg_query(instance, kg_user_client, kg_service_client)
for instance in instances
]

Expand All @@ -251,7 +253,7 @@ def query_tests(
instances[instance["uri"]] = instance # use dict to remove duplicates

return [
cls.from_kg_query(instance, kg_user_client)
cls.from_kg_query(instance, kg_user_client, kg_service_client)
for instance in list(instances.values())[from_index:from_index + size]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def assert_is_valid_url(url):
except ValueError:
raise AssertionError

@pytest.mark.xfail # todo: should pass when using a released instance

def test_get_validation_test_by_id_no_auth():
test_ids = ("01c68387-fcc4-4fd3-85f0-6eb8ce4467a1",)
test_ids = ("90ae68fa-a9e6-49dd-947a-908ab9a6dee2",)
for validation_test_uuid in test_ids:
response = client.get(f"/tests/{validation_test_uuid}")
assert response.status_code == 200
Expand Down Expand Up @@ -92,11 +92,13 @@ def test_get_validation_test_by_id(caplog):
assert response.status_code == 400


@pytest.mark.xfail # test to be updated
def test_list_validation_tests_no_auth():
response = client.get(f"/tests/")
assert response.status_code == 403
assert response.json() == {"detail": "Not authenticated"}
assert response.status_code == 200
validation_tests = response.json()
for validation_test in validation_tests:
check_validation_test(validation_test)
assert validation_test["implementation_status"] == "published"


def test_list_validation_tests_nofilters():
Expand Down

0 comments on commit eeda99e

Please sign in to comment.