Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datacommons_client/endpoints/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def fetch_dcids_by_name(self,

return self.fetch(node_ids=names, expression=expression)

def fetch_dcid_by_wikidata_id(
def fetch_dcids_by_wikidata_id(
self,
wikidata_id: str | list[str],
Comment thread
jm-rivera marked this conversation as resolved.
Outdated
entity_type: Optional[str] = None) -> ResolveResponse:
Expand Down
25 changes: 23 additions & 2 deletions datacommons_client/tests/endpoints/test_resolve_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def test_fetch_dcid_by_wikidata_id():
api_mock = MagicMock(spec=API)
endpoint = ResolveEndpoint(api=api_mock)

response = endpoint.fetch_dcid_by_wikidata_id(wikidata_id="Q12345",
entity_type="Country")
response = endpoint.fetch_dcids_by_wikidata_id(wikidata_id="Q12345",
entity_type="Country")

# Check the response
assert isinstance(response, ResolveResponse)
Expand All @@ -68,6 +68,27 @@ def test_fetch_dcid_by_wikidata_id():
next_token=None)


def test_fetch_dcids_list_by_wikidata_id():
"""Tests the fetch_dcid_by_wikidata_id method."""
api_mock = MagicMock(spec=API)
endpoint = ResolveEndpoint(api=api_mock)

response = endpoint.fetch_dcids_by_wikidata_id(
wikidata_id=["Q12345", "Q695660"])

# Check the response
assert isinstance(response, ResolveResponse)

# Check the post request
api_mock.post.assert_called_once_with(payload={
"nodes": ["Q12345", "Q695660"],
"property": "<-wikidataId->dcid",
},
endpoint="resolve",
all_pages=True,
next_token=None)


def test_fetch_dcid_by_coordinates():
"""Tests the fetch_dcid_by_coordinates method."""
api_mock = MagicMock(spec=API)
Expand Down