Skip to content

Commit

Permalink
FIx dg-api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Reillyhewitson committed Feb 10, 2023
1 parent 21b0233 commit 1ef9eb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions test/datagateway_api/db/endpoints/test_table_endpoints_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_valid_get_facility_cycles_with_filters(
headers=valid_db_credentials_header,
)

assert test_response.json[0] == isis_specific_endpoint_data_db.to_dict()
assert test_response.json[0] == isis_specific_endpoint_data_db[1].to_dict()

def test_invalid_get_facility_cycles_with_filters(
self, flask_test_app_db, valid_db_credentials_header, final_instrument_id,
Expand All @@ -44,7 +44,7 @@ def test_valid_get_facility_cycles_count_with_filters(
headers=valid_db_credentials_header,
)

assert test_response.json == 2
assert test_response.json == 1

def test_invalid_get_facility_cycles_count_with_filters(
self, flask_test_app_db, valid_db_credentials_header, final_instrument_id,
Expand Down
18 changes: 5 additions & 13 deletions test/datagateway_api/icat/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from icat.entity import Entity
import pytest

from datagateway_api.src.common.date_handler import DateHandler
from datagateway_api.src.common.exceptions import PythonICATError
from datagateway_api.src.datagateway_api.icat.filters import (
Expand Down Expand Up @@ -30,9 +29,11 @@ def prepare_icat_data_for_assertion(data, remove_id=False, remove_visit_id=False

for attr in meta_attributes:
entity.pop(attr)
for k, v in entity.items():
if isinstance(v, dict):
entity[k] = pop_nested_attributes(v, meta_attributes)

for key in entity:
if isinstance(entity[key], dict):
for attr in meta_attributes:
entity[key].pop(attr)

for attr in entity.keys():
if isinstance(entity[attr], datetime):
Expand All @@ -45,15 +46,9 @@ def prepare_icat_data_for_assertion(data, remove_id=False, remove_visit_id=False
entity.pop("visitId")

assertable_data.append(entity)

return assertable_data


def pop_nested_attributes(nested_entity, meta_attributes):
for attr in meta_attributes:
nested_entity.pop(attr)


class TestICATQuery:
@pytest.mark.parametrize(
"input_conditions, input_aggregate, input_includes, expected_conditions,"
Expand Down Expand Up @@ -177,12 +172,10 @@ def test_invalid_query_creation(self, icat_client):
"fileCount": 3,
"fileSize": 1073741824,
"facility": {
"createId": "simple/root",
"daysUntilRelease": 10,
"description": "Lorem ipsum light source",
"fullName": None,
"id": 1,
"modId": "simple/root",
"name": "LILS",
"url": None,
},
Expand Down Expand Up @@ -323,7 +316,6 @@ def test_valid_query_execution(
query_data = prepare_icat_data_for_assertion(
query_data, remove_id=True, remove_visit_id=True,
)

assert query_data[0] == expected_query_result[0]

def test_invalid_query_execution(self, icat_client):
Expand Down

0 comments on commit 1ef9eb2

Please sign in to comment.