from nominatim_api.search.postcode_parser import PostcodeParser
from nominatim_api.search.query import QueryStruct, PHRASE_ANY, PHRASE_POSTCODE, PHRASE_STREET
+
@pytest.fixture
def pc_config(project_env):
country_file = project_env.project_dir / 'country_settings.yaml'
return project_env
+
def mk_query(inp):
query = QueryStruct([])
phrase_split = re.split(r"([ ,:'-])", inp)
assert result == {(pos, pos + 1, '45325'), (pos, pos + 1, '453 25')}
+
def test_contained_postcode(pc_config):
parser = PostcodeParser(pc_config)
(0, 2, '12345 DX')}
-
@pytest.mark.parametrize('query,frm,to', [('345987', 0, 1), ('345 987', 0, 2),
('Aina 345 987', 1, 3),
('Aina 23 345 987 ff', 2, 4)])
assert result == {(frm, to, '345987')}
+
def test_overlapping_postcode(pc_config):
parser = PostcodeParser(pc_config)
assert not parser.parse(mk_query('ky12233'))
+
def test_postcode_inside_postcode_phrase(pc_config):
parser = PostcodeParser(pc_config)