Skip to content

Commit

Permalink
#141: Add test cases for distinct attribute mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Apr 12, 2021
1 parent 3401027 commit ede08f2
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/icat/test_query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from icat.entity import Entity
import pytest
Expand Down Expand Up @@ -162,6 +162,22 @@ def test_valid_get_distinct_attributes(self, icat_client):
{"summary": "Summary 1"},
id="Single attribute",
),
pytest.param(
["startDate"],
[
datetime(
year=2020,
month=1,
day=4,
hour=1,
minute=1,
second=1,
tzinfo=timezone.utc,
)
],
{"startDate": "2020-01-04 01:01:01+00:00"},
id="Single date attribute",
),
pytest.param(
["summary", "title"],
["Summary 1", "Title 1"],
Expand All @@ -174,6 +190,17 @@ def test_valid_get_distinct_attributes(self, icat_client):
{"summary": "Summary 1", "investigationUsers": {"role": "PI"}},
id="Multiple attributes with related attribute",
),
pytest.param(
["summary", "investigationUsers.investigation.name"],
["Summary 1", "Investigation Name 1"],
{
"summary": "Summary 1",
"investigationUsers": {
"investigation": {"name": "Investigation Name 1"}
},
},
id="Multiple attributes with 2-level nested related attribute",
),
],
)
def test_valid_map_distinct_attributes_to_results(
Expand Down

0 comments on commit ede08f2

Please sign in to comment.