switch API parameters to keyword arguments

This switches the input parameters for API calls to a generic
keyword argument catch-all which is then loaded into a dataclass
where the parameters are checked and forwarded to internal
function.

The dataclass gives more flexibility with the parameters and makes
it easier to reuse common parameters for the different API calls.
This commit is contained in:
Sarah Hoffmann
2023-05-18 17:42:23 +02:00
parent 8f88613a6b
commit bef5cea48e
10 changed files with 170 additions and 152 deletions

View File

@@ -81,7 +81,7 @@ class TestCliDetailsCall:
napi.Point(1.0, -3.0))
monkeypatch.setattr(napi.NominatimAPI, 'details',
lambda *args: result)
lambda *args, **kwargs: result)
@pytest.mark.parametrize("params", [('--node', '1'),
('--way', '1'),
@@ -106,7 +106,7 @@ class TestCliReverseCall:
extratags={'extra':'Extra'})
monkeypatch.setattr(napi.NominatimAPI, 'reverse',
lambda *args: result)
lambda *args, **kwargs: result)
def test_reverse_simple(self, cli_call, tmp_path, capsys):
@@ -165,7 +165,7 @@ class TestCliLookupCall:
extratags={'extra':'Extra'})
monkeypatch.setattr(napi.NominatimAPI, 'lookup',
lambda *args: napi.SearchResults([result]))
lambda *args, **kwargs: napi.SearchResults([result]))
def test_lookup_simple(self, cli_call, tmp_path, capsys):
result = cli_call('lookup', '--project-dir', str(tmp_path),