diff --git a/tests/enrich/test_nominatim.py b/tests/enrich/test_nominatim.py index 852b6c49..c033a1ec 100644 --- a/tests/enrich/test_nominatim.py +++ b/tests/enrich/test_nominatim.py @@ -66,6 +66,7 @@ def load_enricher(): enricher_cls = get_enricher(PATH) + assert enricher_cls is not None, PATH assert issubclass(enricher_cls, Enricher) cache = Cache.make_default(dataset) return enricher_cls(dataset, cache, {}) @@ -73,7 +74,7 @@ def load_enricher(): def test_nominatim_match(): enricher = load_enricher() - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.get("/search.php", json=RESPONSE) full = "Kopenhagener Str. 47, Berlin" data = {"schema": "Address", "id": "xxx", "properties": {"full": [full]}} @@ -99,7 +100,7 @@ def test_nominatim_match_list(): resolver = Resolver() assert len(resolver.edges) == 0, resolver.edges - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.get("/search.php", json=RESPONSE) results = list(match(enricher, resolver, [ent])) assert len(results) == 2, results @@ -112,7 +113,7 @@ def test_nominatim_enrich(): full = "Kopenhagener Str. 47, Berlin" data = {"schema": "Address", "id": "xxx", "properties": {"full": [full]}} ent = CompositeEntity.from_data(dataset, data) - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.get("/search.php", json=RESPONSE) adjacent = list(enricher.expand(ent, ent)) assert len(adjacent) == 1, adjacent @@ -124,8 +125,9 @@ def test_nominatim_enrich_list(): full = "Kopenhagener Str. 47, Berlin" data = {"schema": "Address", "id": "xxx", "properties": {"full": [full]}} ent = CompositeEntity.from_data(dataset, data) + assert ent.id is not None, ent.id - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.get("/search.php", json=RESPONSE) resolver = Resolver() results = list(enrich(enricher, resolver, [ent])) diff --git a/tests/enrich/test_openfigi.py b/tests/enrich/test_openfigi.py index a7d9b435..10bb49e5 100644 --- a/tests/enrich/test_openfigi.py +++ b/tests/enrich/test_openfigi.py @@ -50,7 +50,7 @@ def load_enricher(): def test_figi_match(): enricher = load_enricher() - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.post("/v3/search", json=RESPONSE) data = { diff --git a/tests/enrich/test_permid.py b/tests/enrich/test_permid.py index 73a9ece5..a0a205f4 100644 --- a/tests/enrich/test_permid.py +++ b/tests/enrich/test_permid.py @@ -165,7 +165,7 @@ def load_enricher(): def test_permid_match(): enricher = load_enricher() - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.post("/permid/match", json=MATCH_ROSNEFT) m.get("https://permid.org/1-4295887083", json=ROSNEFT) m.get("http://sws.geonames.org/2017370/about.rdf", text=GEONAME) @@ -182,7 +182,7 @@ def test_permid_match(): assert res.has("leiCode") assert res.has("name") - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.post("/permid/match", json=MATCH_FAIL) data = { "schema": "Company", @@ -196,7 +196,7 @@ def test_permid_match(): def test_permid_enrich(): enricher = load_enricher() - with requests_mock.Mocker() as m: + with requests_mock.Mocker(real_http=False) as m: m.post("/permid/match", json=MATCH_ROSNEFT) m.get("https://permid.org/1-4295887083", json=ROSNEFT) m.get("http://sws.geonames.org/2017370/about.rdf", text=GEONAME) diff --git a/tests/enrich/test_wikidata.py b/tests/enrich/test_wikidata.py index 07bf5b5e..2dcef927 100644 --- a/tests/enrich/test_wikidata.py +++ b/tests/enrich/test_wikidata.py @@ -1,4 +1,3 @@ -from followthemoney import model from nomenklatura.cache import Cache from nomenklatura.dataset import Dataset from nomenklatura.enrich import get_enricher @@ -10,8 +9,10 @@ PATH = "nomenklatura.enrich.wikidata:WikidataEnricher" dataset = Dataset.make({"name": "wikidata", "title": "Wikidata"}) + def load_enricher(): enricher_cls = get_enricher(PATH) + assert enricher_cls is not None, PATH assert issubclass(enricher_cls, Enricher) cache = Cache.make_default(dataset) return enricher_cls(dataset, cache, {}) @@ -51,4 +52,4 @@ def test_model_apply(): dirty = LangText("clean part (politician)", "en") dirty.apply(ent, "alias", clean=clean_name) - assert ent.get("alias") == ["clean part"] \ No newline at end of file + assert ent.get("alias") == ["clean part"]