Skip to content

Commit 8aab67d

Browse files
committed
One more test for Gramps types
1 parent 8e8fa2c commit 8aab67d

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

tests/test_endpoints/test_post.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def test_add_people_quota_objects(self):
709709
rv = self.client.post("/api/objects/", json=people[:4], headers=headers)
710710
assert rv.status_code == 405
711711

712-
def test_objects_add_person_types(self):
712+
def test_add_person_types(self):
713713
"""Add a person and check that types are handled correctly even
714714
when using incomplete dicts."""
715715
handle_person = make_handle()
@@ -739,11 +739,49 @@ def test_objects_add_person_types(self):
739739
out = rv.json
740740
assert len(out) == 1
741741
rv = self.client.get(
742-
f"/api/people/{handle_person}?extend=event_ref_list&locale=de",
742+
f"/api/people/{handle_person}?locale=de",
743743
headers=headers,
744744
)
745745
assert rv.status_code == 200
746746
person_dict = rv.json
747747
assert person_dict["primary_name"]["first_name"] == "John"
748748
assert person_dict["primary_name"]["surname_list"][0]["surname"] == "Doe"
749749
assert person_dict["primary_name"]["type"] == "Married Name"
750+
751+
def test_add_event_types(self):
752+
handle_event = make_handle()
753+
event = {
754+
"handle": handle_event,
755+
"change": 1746095141,
756+
"date": {
757+
"format": None,
758+
"calendar": 0,
759+
"modifier": 0,
760+
"quality": 0,
761+
"dateval": [2, 2, 1991, False],
762+
},
763+
"_class": "Event",
764+
"type": "Adopted",
765+
}
766+
headers = get_headers(self.client, "admin", "123")
767+
rv = self.client.post("/api/events/", headers=headers)
768+
rv = self.client.get("/api/events/", headers=headers)
769+
handles = [obj["handle"] for obj in rv.json]
770+
# delete existing events
771+
for handle in handles:
772+
self.client.delete(f"/api/events/{handle}", headers=headers)
773+
rv = self.client.post("/api/events/", json=event, headers=headers)
774+
self.assertEqual(rv.status_code, 201)
775+
# check return value
776+
out = rv.json
777+
assert len(out) == 1
778+
rv = self.client.get(
779+
f"/api/events/{handle_event}?locale=de&profile=self",
780+
headers=headers,
781+
)
782+
assert rv.status_code == 200
783+
event_dict = rv.json
784+
assert event_dict["type"] == "Adopted"
785+
# This being correctly translated tests that the type has been correctly
786+
# detected as a default type rather than a custom type
787+
assert event_dict["profile"]["type"] == "Adoptiert"

0 commit comments

Comments
 (0)