Skip to content

Commit

Permalink
Query URL woes
Browse files Browse the repository at this point in the history
nominatim-docker-test: Updating geofabrik url variable, in hopes that it will be able to be passed into a call in TestNominatim.py. I have looked into it more, and I'm not sure if GH actions allows this.

nominatim.py: Realized that some of my assertion errors might be related to the nominatim url environment variable not getting set properly locally, so comparing local url to the one produced in github actions.

TestNominatim,py: Changing expected result for get_filtered_place. Difference was due to my error.
  • Loading branch information
nataliejschultz committed Sep 14, 2023
1 parent 86d51e4 commit eba9d4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nominatim-docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:

- name: Test nominatim
env:
GEOFABRIK_QUERY_URL: https://geocoding.geofabrik.de/${{secrets.GEOFABRIK_API}}
GEOFABRIK_QUERY_URL: "https://geocoding.geofabrik.de/${{secrets.GEOFABRIK_API}}""
run: docker-compose -f emission/integrationTests/docker-compose.yml up --exit-code-from web-server
8 changes: 4 additions & 4 deletions emission/individual_tests/TestNominatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#temporarily sets NOMINATIM_QUERY_URL to the environment variable for testing.
NOMINATIM_QUERY_URL_env = os.environ.get("NOMINATIM_QUERY_URL", "")
NOMINATIM_QUERY_URL = NOMINATIM_QUERY_URL_env if NOMINATIM_QUERY_URL_env != "" else eco.NOMINATIM_QUERY_URL
GEOFABRIK_QUERY_URL = os.environ.get("GEOFABRIK_QUERY_URL", "")
GEOFABRIK_QUERY_URL = os.environ.get("GEOFABRIK_QUERY_URL")
# GEOFABRIK_QUERY_URL = os.environ["GEOFABRIK_QUERY_URL"]

#Creates a fake place in Rhode Island to use for testing.
fake_id = "rhodeislander"
Expand All @@ -42,8 +43,9 @@ def test_geofabrik_and_nominatim(self):
# and reverse geocodes with the coordinates.
def test_get_filtered_place(self):
raw_result = ecww.WrapperBase.__getattr__(clean.get_filtered_place(fake_place), "data")
print(NOMINATIM_QUERY_URL)
actual_result = ecww.WrapperBase.__getattr__(raw_result, "display_name")
expected_result = "Fulton Street, Providence"
expected_result = "Dorrance Street, Providence"
self.assertEqual(expected_result, actual_result)

def test_make_url_geo(self):
Expand Down Expand Up @@ -90,9 +92,7 @@ def test_nominatim_api(self):
nominatim_result = nominatim_result_raw.json()['display_name']
# NOMINATIM_QUERY_URL = eco.NOMINATIM_QUERY_URL
docker_result = eco.Geocoder.reverse_geocode(41.832942092439694, -71.41558148857203)
print("HEYYY")
print(docker_result)
print("hey2")
print(nominatim_result)
self.assertEqual(nominatim_result, docker_result)

Expand Down
1 change: 1 addition & 0 deletions emission/net/ext_service/geocoder/nominatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from emission.core.wrapper.trip_old import Coordinate
try:
NOMINATIM_QUERY_URL_env = os.environ.get("NOMINATIM_QUERY_URL", "")
logging.info(f"NOMINATIM_QUERY_URL_env: {NOMINATIM_QUERY_URL_env}")
NOMINATIM_QUERY_URL = NOMINATIM_QUERY_URL_env if NOMINATIM_QUERY_URL_env != "" else "http://nominatim.openstreetmap.org"

except:
Expand Down

0 comments on commit eba9d4d

Please sign in to comment.