Alpha stage commit
This commit is contained in:
33
tests/test_address_search.py
Normal file
33
tests/test_address_search.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.address_search import _folded_query_candidates, _numbered_query_candidates, coordinate_token, parse_coordinate_token
|
||||
|
||||
|
||||
def test_numbered_address_query_accepts_city_first_without_comma():
|
||||
assert ("alexanderplatz", "1", "berlin") in _numbered_query_candidates("Berlin Alexanderplatz 1")
|
||||
|
||||
|
||||
def test_numbered_address_query_accepts_city_last_without_comma():
|
||||
assert ("alexanderplatz", "1", "berlin") in _numbered_query_candidates("Alexanderplatz 1 Berlin")
|
||||
|
||||
|
||||
def test_numbered_address_query_prefers_comma_locality():
|
||||
assert _numbered_query_candidates("Berlin, Alexanderplatz 1")[0] == ("alexanderplatz", "1", "berlin")
|
||||
|
||||
|
||||
def test_folded_address_query_accepts_city_first_without_comma():
|
||||
assert ("alexanderplatz", "berlin") in _folded_query_candidates("Berlin Alexanderplatz")
|
||||
|
||||
|
||||
def test_folded_address_query_accepts_city_last_without_comma():
|
||||
assert ("alexanderplatz", "berlin") in _folded_query_candidates("Alexanderplatz Berlin")
|
||||
|
||||
|
||||
def test_folded_address_query_prefers_comma_locality():
|
||||
assert _folded_query_candidates("Berlin, Alexanderplatz")[0] == ("alexanderplatz", "berlin")
|
||||
|
||||
|
||||
def test_coordinate_token_round_trips():
|
||||
token = coordinate_token(49.404539659, 8.685940101)
|
||||
assert token == "coord:49.4045397:8.6859401"
|
||||
assert parse_coordinate_token(token) == (49.4045397, 8.6859401)
|
||||
Reference in New Issue
Block a user