From f907a4968d8bd287ff27536b560a5559f883d5ea Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 9 Jul 2024 16:19:58 +0200 Subject: [PATCH] fix `events.is_new_version` when translations are None SDCP-794 SDCP-795 --- server/planning/events/events.py | 2 +- server/planning/tests/events_service_test.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/planning/events/events.py b/server/planning/events/events.py index 5364251cb..b6f41bbc3 100644 --- a/server/planning/events/events.py +++ b/server/planning/events/events.py @@ -109,7 +109,7 @@ def get_subject_str(subject: Dict[str, str]) -> str: subject.get("name", ""), subject.get("qcode", ""), subject.get("scheme", ""), - subject.get("translations", ""), + str(subject.get("translations", "")), ] ) diff --git a/server/planning/tests/events_service_test.py b/server/planning/tests/events_service_test.py index 9dce29300..77cc09a1a 100644 --- a/server/planning/tests/events_service_test.py +++ b/server/planning/tests/events_service_test.py @@ -37,6 +37,16 @@ def test_is_new_version(): assert service.is_new_version(new_event, old_event) + new_event["subject"] = [{"qcode": "foo", "name": "foo", "translations": {"fr-CA": "Foo"}}] + old_event["subject"] = [{"qcode": "foo", "name": "foo", "translations": None}] + + assert service.is_new_version(new_event, old_event) + + new_event["subject"] = [{"qcode": "foo", "name": "foo", "translations": {"fr-CA": "Bar"}}] + old_event["subject"] = [{"qcode": "foo", "name": "foo", "translations": {"fr-CA": "Foo"}}] + + assert service.is_new_version(new_event, old_event) + def test_should_update(): service = EventsService()