Commit b43b02f9 authored by Trond Aasan's avatar Trond Aasan
Browse files

CIM-58 Raise TypeError if person isn't an instance of PersonBase

parent a59c9319
Pipeline #79442 passed with stages
in 2 minutes and 5 seconds
......@@ -38,6 +38,9 @@ def _serialise_upsert_person(
A phone field is reset when the corresponding key is omitted.
Neither "" nor null are allowed values.
if not isinstance(person, PersonBase):
raise TypeError("Expected person to be an instance of PersonBase")
empty_phone_fields = {
for f in {
......@@ -158,6 +158,22 @@ def test_upsert_persons_many(client, john_doe, jane_doe, requests_mock):
assert response.status_code == 200
def test_upsert_persons_one_wrong_type_raises_type_error(
client, john_doe, requests_mock
with pytest.raises(TypeError):
client.upsert_persons("Sesam, sesam") # type: ignore
def test_upsert_persons_many_wrong_type_raises_type_error(
client, john_doe, requests_mock
data = [Person.from_dict(john_doe), 12]
with pytest.raises(TypeError):
client.upsert_persons(data) # type: ignore
def test_upsert_persons_failure_400(client, john_doe, requests_mock):
"""Ensure 400 raises an error""", status_code=400)
......@@ -234,3 +250,9 @@ def test__serialise_upsert_person():
assert "secret_number" not in keys
assert "private_mobile" not in keys
assert "private_phone" not in keys
def test__serialise_upsert_person_wrong_type_raises_type_error():
p = "Hey babiluba"
with pytest.raises(TypeError):
_serialise_upsert_person(p) # type: ignore
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment