Merge remote-tracking branch 'origin/dev' into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-08-04 09:16:32 +02:00
4 changed files with 37 additions and 3 deletions
@@ -361,6 +361,7 @@ class InstitutionsSearchClient:
"government",
"facility",
"other",
"funder",
}
cleaned_source = {}
@@ -33,6 +33,7 @@ _VALID_INSTITUTION_TYPES = {
"government",
"facility",
"other",
"funder",
}
@@ -174,3 +174,34 @@ async def test_list_institutions_accepts_practical_openalex_type_variants():
assert result.results[0].counts_by_year[0].cited_by_count is None
assert result.group_by[0].key == "true"
@pytest.mark.anyio
async def test_list_institutions_accepts_funder_institution_type():
def handler(_: httpx.Request) -> httpx.Response:
return httpx.Response(
200,
json={
"meta": {"count": 1, "page": 1, "per_page": 25},
"results": [
{
"id": "https://openalex.org/I4210119759",
"display_name": "Essen University Hospital",
"country_code": "DE",
"type": "funder",
}
],
},
)
client = OpenAlexInstitutionsClient(
api_key="test-key",
transport=httpx.MockTransport(handler),
)
result = await logic.list_institutions(client=client)
assert result.results[0].id == "https://openalex.org/I4210119759"
assert result.results[0].display_name == "Essen University Hospital"
assert result.results[0].type == "funder"
@@ -37,7 +37,7 @@ class Institution(BaseModel):
ror: StrictStr | None = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.")
display_name: StrictStr | None = Field(default=None, description="The primary name of the institution.")
country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this institution is located.")
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.")
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`, `Funder`.")
homepage_url: StrictStr | None = Field(default=None, description="URL for the institution's primary homepage.")
image_url: StrictStr | None = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).")
image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.")
@@ -61,8 +61,9 @@ class Institution(BaseModel):
if value is None:
return value
if value not in set(['education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other']):
raise ValueError("must be one of enum values ('education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other')")
valid_types = {'education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other', 'funder'}
if value not in valid_types:
return 'other'
return value
model_config = ConfigDict(