Skip to content

Commit

Permalink
country endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oyeniyipa committed Feb 24, 2025
1 parent 07bf290 commit 76d7271
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion profiles/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 7 additions & 0 deletions profiles/services/peoplefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
17 changes: 17 additions & 0 deletions profiles/tests/test_services_peoplefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 76d7271

Please sign in to comment.