Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Cordeiro committed Mar 19, 2024
1 parent 5f0c6fd commit 88f8779
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions tests/endpoints/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,18 @@ def test_place_schema():
assert Place(id="some_id", type="some_type", name="some_name", location=[32.123, -84.123]).location == (32.123, -84.123)


def test_event_schema():
with pytest.raises(ValidationError):
Event(id="some_id",
category="some_category",
country="some_country",
county="some_county",
start="2023-12-01T00:00:00Z",
title="some_title",
labels=["some_labels"],
phq_labels=PHQLabels.parse_obj({"key": "value"}))

with pytest.raises(ValidationError):
Event(id="some_id",
category="some_category",
country="some_country",
county="some_county",
start="2023-12-01T00:00:00Z",
title="some_title",
labels=["some_labels"],
phq_labels=[PHQLabels.parse_obj({5: "value"})])

assert Event(id="some_id",
category="some_category",
country="some_country",
county="some_county",
start="2023-12-01T00:00:00Z",
title="some_title",
labels=["some_labels"],
phq_labels=[PHQLabels.parse_obj({"label": "holiday", "weight": 2.0})])
@pytest.mark.parametrize("phq_labels,raise_validation_error", [({"label": 34, "weight": "holiday"}, True), # wrong type
({"weight": 2.0}, True), # missing label
({"label": "holiday"}, True), # missing weight
({"label": "holiday", "weight": 2.0}, False)]) # correct
def test_event_schema(phq_labels, raise_validation_error):
if raise_validation_error:
with pytest.raises(ValidationError) as e:
label = PHQLabels.parse_obj(phq_labels)
else:
label = PHQLabels.parse_obj(phq_labels)
assert label.label == phq_labels["label"]
assert label.weight == phq_labels["weight"]


def test_resultset():
Expand Down

0 comments on commit 88f8779

Please sign in to comment.