diff --git a/bin/createfakeplace.py b/bin/createfakeplace.py new file mode 100644 index 000000000..cfebb6a1c --- /dev/null +++ b/bin/createfakeplace.py @@ -0,0 +1,10 @@ +import emission.core.wrapper.entry as ecwe + +#Creates a fake, cleaned place in Rhode Island for use in TestNominatim.py: +def create_fake_place(): + fake_id = "place_in_rhodeisland" + key = "segmentation/raw_place" + write_ts = 1694344333 + data = {'source': 'FakeTripGenerator','location': {'type': 'Point', 'coordinates': [-71.4128343, 41.8239891]}} + fake_place = ecwe.Entry.create_fake_entry(fake_id, key, data, write_ts) + return fake_place \ No newline at end of file diff --git a/emission/individual_tests/TestNominatim.py b/emission/individual_tests/TestNominatim.py index 5de84751e..241adc29a 100644 --- a/emission/individual_tests/TestNominatim.py +++ b/emission/individual_tests/TestNominatim.py @@ -9,6 +9,7 @@ import os from emission.core.wrapper.trip_old import Coordinate import requests +import bin.createfakeplace as bc import emission.core.wrapper.entry as ecwe import emission.net.ext_service.geocoder.nominatim as eco import emission.analysis.intake.cleaning.clean_and_resample as clean @@ -27,14 +28,6 @@ "https://geocoding.geofabrik.de/{}".format(GFBK) if GFBK is not None else print("No key available") ) - -#Creates a fake place in Rhode Island to use for testing. -fake_id = "rhodeislander" -key = "segmentation/raw_place" -write_ts = 1694344333 -data = {'source': 'FakeTripGenerator','location': {'type': 'Point', 'coordinates': [-71.4128343, 41.8239891]}} -fake_place = ecwe.Entry.create_fake_entry(fake_id, key, data, write_ts) - class NominatimTest(unittest.TestCase): maxDiff = None @@ -49,9 +42,9 @@ def test_geofabrik_and_nominatim(self): #Checks the display name generated by get_filtered_place in clean_and_resample.py, which creates a cleaned place from the fake place # and reverse geocodes with the coordinates. def test_get_filtered_place(self): - raw_result = ecwe.Entry.__getattr__(clean.get_filtered_place(fake_place), "data") - print(OPENSTREETMAP_QUERY_URL) - actual_result = ecwe.Entry.__getattr__(raw_result, "display_name") + fake_place_raw = bc.create_fake_place() + fake_place_data = clean.get_filtered_place(fake_place_raw).__getattr__("data") + actual_result = fake_place_data.__getattr__("display_name") expected_result = "Dorrance Street, Providence" self.assertEqual(expected_result, actual_result) diff --git a/emission/integrationTests/Dockerfile b/emission/integrationTests/Dockerfile index 27587b225..9bdc0484d 100644 --- a/emission/integrationTests/Dockerfile +++ b/emission/integrationTests/Dockerfile @@ -2,18 +2,11 @@ FROM ubuntu:latest RUN apt-get update -RUN apt-get install -y curl wget +RUN apt-get install -y curl # CHANGEME: Create the files that correspond to your configuration in the conf directory -# COPY conf/net/auth/google_auth.json /usr/src/app/conf/net/auth/google_auth.json - -ENV DOCKERIZE_VERSION v0.5.0 -RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz RUN echo "About to copy e-mission server code" COPY start_integration_tests.sh/ /start_integration_tests.sh -# CMD ["python", "../individual_tests/TestNominatim.py"] CMD ["/bin/bash", "/start_integration_tests.sh"] \ No newline at end of file diff --git a/emission/integrationTests/start_integration_tests.sh b/emission/integrationTests/start_integration_tests.sh index 004fb524f..fa69e3b4d 100644 --- a/emission/integrationTests/start_integration_tests.sh +++ b/emission/integrationTests/start_integration_tests.sh @@ -15,10 +15,8 @@ cat conf/storage/db.conf echo "Setting up conda..." source setup/setup_conda.sh Linux-x86_64 - echo "Setting up the test environment..." -source setup/setup_tests.sh - +source setup/setup_integrationtests.sh echo "Running tests..." source setup/activate_tests.sh @@ -27,7 +25,4 @@ echo "Adding permissions for the runIntegrationTests.sh script" chmod +x runIntegrationTests.sh echo "Permissions added for the runIntegrationTests.sh script" -echo "Dockerize running!" -dockerize -wait http://rhodeisland-nominatim:8080 -timeout 240s -echo "Dockerize done! Running integration tests:" ./runIntegrationTests.sh \ No newline at end of file diff --git a/setup/docker-compose.tests.yml b/setup/docker-compose.tests.yml index 74b34e597..b35ee0cd6 100644 --- a/setup/docker-compose.tests.yml +++ b/setup/docker-compose.tests.yml @@ -32,7 +32,6 @@ services: networks: - emission - networks: emission: diff --git a/setup/setup_integrationtests.sh b/setup/setup_integrationtests.sh new file mode 100644 index 000000000..72de46840 --- /dev/null +++ b/setup/setup_integrationtests.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source setup/checks/check_for_conda.sh + +conda env update --name emissiontest --file setup/environment36.yml +# python bin/deploy/habitica_conf.py +python bin/deploy/push_conf.py +python bin/deploy/model_copy.py +python bin/createfakeplace.py