diff --git a/profiles/services/__init__.py b/profiles/services/__init__.py index 3216b2c9..b2a4cd8a 100644 --- a/profiles/services/__init__.py +++ b/profiles/services/__init__.py @@ -404,4 +404,4 @@ def get_countries() -> list[Country]: """ Gets all countries service """ - return [country for country in Country.objects.all()] + return peoplefinder.get_countries() diff --git a/profiles/services/peoplefinder.py b/profiles/services/peoplefinder.py index 46ee3705..85befd53 100644 --- a/profiles/services/peoplefinder.py +++ b/profiles/services/peoplefinder.py @@ -421,3 +421,10 @@ def delete_from_database( ) peoplefinder_profile.delete() + + +def get_countries() -> list[Country]: + """ + Gets all countries service + """ + return [country for country in Country.objects.all()] diff --git a/profiles/tests/test_services_peoplefinder.py b/profiles/tests/test_services_peoplefinder.py index a3c3abad..39011bf2 100644 --- a/profiles/tests/test_services_peoplefinder.py +++ b/profiles/tests/test_services_peoplefinder.py @@ -111,3 +111,20 @@ def test_get_by_id(peoplefinder_profile): with pytest.raises(PeopleFinderProfile.DoesNotExist) as ex: peoplefinder_services.get_by_slug(slug="550e8400-e29b-41d4-a716-446655440000") assert str(ex.value.args[0]) == "PeopleFinderProfile matching query does not exist." + + +def test_get_countries(): + countries = peoplefinder_services.get_countries() + # Check if country properties exist in fetched country + expected = { + "reference_id": "CTHMTC00260", + "name": "UK", + "type": "country", + "iso_1_code": "31", + "iso_2_code": "66", + "iso_3_code": "2", + "overseas_region": None, + "start_date": None, + "end_date": None, + } + assert expected.items() <= countries[0].__dict__.items()