Format Python source and tests
This commit is contained in:
parent
45dc2c2e67
commit
fb9bb532ec
8 changed files with 31 additions and 22 deletions
|
|
@ -63,9 +63,9 @@ def capture_sample(i: int, lat: float, lon: float, name: str) -> None:
|
|||
"wdqs": wdqs_calls,
|
||||
"api": api_calls,
|
||||
"expected_wikidata": result.get("wikidata"),
|
||||
"expected_commons_cat": commons_cat["title"]
|
||||
if isinstance(commons_cat, dict)
|
||||
else None,
|
||||
"expected_commons_cat": (
|
||||
commons_cat["title"] if isinstance(commons_cat, dict) else None
|
||||
),
|
||||
}
|
||||
|
||||
fixture_path = FIXTURES_DIR / f"sample_{i:02d}.json"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import pytest
|
|||
def flask_app():
|
||||
"""Return the Flask application."""
|
||||
from lookup import app
|
||||
|
||||
return app
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_invalid_coordinates_return_400(monkeypatch, parameter, value):
|
|||
"lat, lon, expected",
|
||||
[
|
||||
("55.7644", "-4.177", (55.7644, -4.177)),
|
||||
('56°6\'0"N', '3°30\'0"W', (56.1, -3.5)),
|
||||
("56°6'0\"N", "3°30'0\"W", (56.1, -3.5)),
|
||||
("-90", "180", (-90.0, 180.0)),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -83,14 +83,14 @@ def test_example(app_ctx, mocker, i: int, lat: float, lon: float, name: str) ->
|
|||
expected_cat = fixture["expected_commons_cat"]
|
||||
if expected_cat:
|
||||
commons = result.get("commons_cat")
|
||||
assert isinstance(commons, dict), (
|
||||
f"{name}: expected commons_cat={expected_cat!r} but result has none"
|
||||
)
|
||||
assert isinstance(
|
||||
commons, dict
|
||||
), f"{name}: expected commons_cat={expected_cat!r} but result has none"
|
||||
assert commons["title"] == expected_cat, (
|
||||
f"{name}: commons_cat mismatch — expected {expected_cat!r}, "
|
||||
f"got {commons['title']!r}"
|
||||
)
|
||||
else:
|
||||
assert not result.get("commons_cat"), (
|
||||
f"{name}: expected no commons_cat but got {result.get('commons_cat')!r}"
|
||||
)
|
||||
assert not result.get(
|
||||
"commons_cat"
|
||||
), f"{name}: expected no commons_cat but got {result.get('commons_cat')!r}"
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import pytest
|
|||
import pytest_mock
|
||||
import requests
|
||||
import responses
|
||||
|
||||
from geocode import headers
|
||||
from geocode.wikimedia_api_logging import WikimediaApiLogConfig
|
||||
from geocode.wikidata import (
|
||||
APIResponseError,
|
||||
QueryError,
|
||||
|
|
@ -14,6 +14,7 @@ from geocode.wikidata import (
|
|||
mediawiki_error_message,
|
||||
wdqs,
|
||||
)
|
||||
from geocode.wikimedia_api_logging import WikimediaApiLogConfig
|
||||
|
||||
max_tries = 5
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue