Skip to content

Commit

Permalink
Env variable testing + changing test_get_json_geo
Browse files Browse the repository at this point in the history
Added multiple tests to see if I can access the fake API key I added to GH actions secrets.

Modified the test for the get_json_geo function to only look for the name of the returned place.
  • Loading branch information
nataliejschultz committed Sep 15, 2023
1 parent 18ba878 commit 53c3e1e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions emission/individual_tests/TestNominatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
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["GEOFABRIK_QUERY_URL"]

TEST_ENVVAR = os.environ["TEST_ENVVAR"]
TEST_2ENVVAR = os.environ.get("TEST_ENVVAR")
TEST_KEY = os.environ["TEST_KEY"]
TEST_2KEY = os.environ.get("TEST_KEY")
print("first method", TEST_ENVVAR)
print("get method", TEST_2ENVVAR)
print("first metho key", TEST_KEY)
print("get method key", TEST_2KEY)
#Creates a fake place in Rhode Island to use for testing.
fake_id = "rhodeislander"
key = "segmentation/raw_place"
Expand Down Expand Up @@ -55,8 +61,8 @@ def test_make_url_geo(self):

#we ignore the place_id because it is an internal Nominatim identifier
def test_get_json_geo(self):
expected_result = [{'place_id': mock.ANY, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'way', 'osm_id': 121496393, 'boundingbox': ['41.8237547', '41.8243153', '-71.4132816', '-71.4125278'], 'lat': '41.824034499999996', 'lon': '-71.41290469687814', 'display_name': 'Providence City Hall, Fulton Street, Downtown, Providence, Providence County, 02903, United States', 'class': 'amenity', 'type': 'townhall', 'importance': 1.25001}]
actual_result = eco.Geocoder.get_json_geo("Providence City Hall, Fulton Street, Downtown, Providence, Providence County, 02903, United States")
expected_result = "Hartford Pike"
actual_result = eco.Geocoder.get_json_geo("Old Hartford Pike, Scituate, RI 02857")[0]["name"]
self.assertEqual(expected_result, actual_result)

def test_geocode(self):
Expand Down

0 comments on commit 53c3e1e

Please sign in to comment.