Skip to content

Commit

Permalink
Fix regions staying as dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 3, 2024
1 parent 6a31849 commit e788391
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/ngohub/normalization/organization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List

from ngohub.models.locations import CityBase, County
from ngohub.models.locations import CityBase, County, Region
from ngohub.models.nomenclatures import Domain
from ngohub.models.organization import (
Application,
Expand Down Expand Up @@ -37,10 +37,15 @@ def _normalize_organization_general(org_general_data: Dict) -> OrganizationGener

def _normalize_organization_activity(org_activity_data: Dict) -> OrganizationActivity:
org_domains: List[Domain] = []
org_regions: List[Region] = []
for domain in org_activity_data["domains"]:
org_domains.append(Domain(**domain))
for region in org_activity_data["regions"]:
org_regions.append(Region(**region))

org_activity_data["domains"] = org_domains
org_activity_data["regions"] = org_regions

normal_data = OrganizationActivity(**org_activity_data)

return normal_data
Expand Down
6 changes: 4 additions & 2 deletions tests/test_end_to_end/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
ORGANIZATION_SCHEMA,
)

TEST_ORGANIZATION_IDS = [1, 10, 23, 296]


def test_organization_profile():
hub = NGOHub(pytest.ngohub_api_url)
Expand All @@ -25,7 +27,7 @@ def test_organization_profile_returns_401():
hub.get_raw_organization_profile(ngo_token="invalid_token")


@pytest.mark.parametrize("organization_id", [1, 10, 23, 296])
@pytest.mark.parametrize("organization_id", TEST_ORGANIZATION_IDS)
def test_raw_organization(organization_id):
hub = NGOHub(pytest.ngohub_api_url)

Expand All @@ -34,7 +36,7 @@ def test_raw_organization(organization_id):
assert ORGANIZATION_SCHEMA.validate(response)


@pytest.mark.parametrize("organization_id", [1, 10, 23, 296])
@pytest.mark.parametrize("organization_id", TEST_ORGANIZATION_IDS)
def test_organization(organization_id):
hub = NGOHub(pytest.ngohub_api_url)

Expand Down

0 comments on commit e788391

Please sign in to comment.