1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Tests for loading of parameter dataclasses.
12 from nominatim_api.errors import UsageError
13 import nominatim_api.types as typ
15 def test_no_params_defaults():
16 params = typ.LookupDetails.from_kwargs({})
18 assert not params.parented_places
19 assert params.geometry_simplification == 0.0
22 @pytest.mark.parametrize('k,v', [('geometry_output', 'a'),
24 ('geometry_simplification', 'NaN')])
25 def test_bad_format_reverse(k, v):
26 with pytest.raises(UsageError):
27 params = typ.ReverseDetails.from_kwargs({k: v})
30 @pytest.mark.parametrize('rin,rout', [(-23, 0), (0, 0), (1, 1),
31 (15, 15), (30, 30), (31, 30)])
32 def test_rank_params(rin, rout):
33 params = typ.ReverseDetails.from_kwargs({'max_rank': rin})
35 assert params.max_rank == rout