-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TheScienceMuseum/develop
v0.3.4: get_labels
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from elastic_wikidata import wd_entities | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def ge(): | ||
ge = wd_entities.get_entities() | ||
|
||
return ge | ||
|
||
|
||
def test_get_all_results(ge): | ||
qids = ["Q203545", "Q706475", "Q18637243"] | ||
|
||
res = ge.get_all_results(qids, timeout=6) | ||
|
||
assert isinstance(res, list) | ||
assert len(res) == len(qids) | ||
assert [item["id"] for item in res] == qids | ||
|
||
|
||
def test_get_labels(ge): | ||
qids = ["Q203545", "Q706475", "Q18637243", "Q82340"] | ||
|
||
label_dict = ge.get_labels(qids, timeout=6) | ||
|
||
# the last QID has no english label so a blank string is returned as its value | ||
assert label_dict == { | ||
"Q18637243": "Michaela Coel", | ||
"Q203545": "Michael Gambon", | ||
"Q706475": "Steve McQueen", | ||
"Q82340": "", | ||
} |