-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/use gb full #18
base: main
Are you sure you want to change the base?
Changes from 8 commits
dc75889
3990bf2
a7399c4
1d3a297
21baf23
e56ad3f
3d56aad
fb449c4
a391b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,3 +101,7 @@ ENV/ | |
.mypy_cache/ | ||
_build/ | ||
generated/ | ||
|
||
# PyCharm | ||
.idea/ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,11 @@ def temp_dir(): | |||||
shutil.rmtree(path) | ||||||
|
||||||
|
||||||
@pytest.fixture(scope='session') | ||||||
def country_gb_full(): | ||||||
return pgeocode._Country('gb_full') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typically session level fixtures are used for expensive operation (e.g. loading the data, or file access operations) once per session run. To test |
||||||
|
||||||
|
||||||
def _normalize_str(x): | ||||||
if x is np.nan: | ||||||
return x | ||||||
|
@@ -85,6 +90,27 @@ def test_download_dataset(temp_dir): | |||||
assert len(res2.place_name.split(',')) > 1 | ||||||
|
||||||
|
||||||
def test_download_gb_full_dataset(temp_dir): | ||||||
assert not os.path.exists(os.path.join(temp_dir, 'GB_full.txt')) | ||||||
nomi = Nominatim('gb_full') | ||||||
# the data file was downloaded | ||||||
assert os.path.exists(os.path.join(temp_dir, 'GB_full.txt')) | ||||||
res = nomi.query_postal_code('BS6 5JR') | ||||||
|
||||||
nomi2 = Nominatim('gb_full') | ||||||
res2 = nomi.query_postal_code('BS65JR') | ||||||
|
||||||
assert_array_equal(nomi._data.columns, | ||||||
nomi2._data.columns) | ||||||
assert_array_equal(nomi._data_frame.columns, | ||||||
nomi2._data_frame.columns) | ||||||
assert nomi._data.shape == nomi._data.shape | ||||||
assert nomi._data_frame.shape == nomi._data_frame.shape | ||||||
|
||||||
assert res.place_name == 'Bristol' | ||||||
assert res2.place_name == 'Bristol' | ||||||
|
||||||
|
||||||
amarchin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
def test_nominatim_query_postal_code(): | ||||||
nomi = Nominatim('fr') | ||||||
|
||||||
|
@@ -172,3 +198,26 @@ def test_haversine_distance(): | |||||
d_pred = haversine_distance(x, y) | ||||||
# same distance +/- 3 km | ||||||
assert_allclose(d_ref, d_pred, atol=3) | ||||||
|
||||||
|
||||||
def test_that_get_clean_country_raises_value_error(): | ||||||
with pytest.raises(ValueError): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
pgeocode._Country('invalid') | ||||||
|
||||||
|
||||||
def test_that_get_clean_country_handles_gb_full(country_gb_full): | ||||||
assert country_gb_full.name == 'GB_full' | ||||||
|
||||||
|
||||||
def test_that_get_clean_country_works_for_valid_countries(): | ||||||
country_obj = pgeocode._Country('ES') | ||||||
assert country_obj.name == 'ES' | ||||||
|
||||||
|
||||||
def test_that_get_download_path_handles_gb_full(country_gb_full): | ||||||
assert country_gb_full.get_download_path() == "https://download.geonames.org/export/zip/GB_full.csv.zip" | ||||||
|
||||||
|
||||||
def test_that_get_download_path_works_for_valid_countries(): | ||||||
country_obj = pgeocode._Country('CA') | ||||||
assert country_obj.get_download_path() == "https://download.geonames.org/export/zip/CA.zip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this private as well,