From 53c3e1ee473ba5c143da60d4fd21dc35b5b5c426 Mon Sep 17 00:00:00 2001 From: Natalie Schultz <90212258+nataliejschultz@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:57:21 -0600 Subject: [PATCH] Env variable testing + changing test_get_json_geo 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. --- emission/individual_tests/TestNominatim.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/emission/individual_tests/TestNominatim.py b/emission/individual_tests/TestNominatim.py index 6a8cbe335..91c0c3fd1 100644 --- a/emission/individual_tests/TestNominatim.py +++ b/emission/individual_tests/TestNominatim.py @@ -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" @@ -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):