Skip to content

Commit

Permalink
createfakeplace.py + removing dockerize + setup_integrationtests.sh
Browse files Browse the repository at this point in the history
docker-compose.tests.yml: removing whitespace (My test doesn't use this file, so it must have been added there on accident)

dockerfile: removing dockerize and extra print

start_integration_tests: removing dockerize wait command and some extra whitespaces

setup_integrationtests.sh: created a new shell script that's separate from setup_tests.sh. essentially the same, but added a line to run createfakeplace.py

createfakeplace.py: creates a fake place to be used in testnominatim.py

testnominatim.py: added functionality for createfakeplace.py.
  • Loading branch information
nataliejschultz committed Oct 3, 2023
1 parent 8a6d339 commit 1e90c65
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
10 changes: 10 additions & 0 deletions bin/createfakeplace.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 4 additions & 11 deletions emission/individual_tests/TestNominatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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)

Expand Down
9 changes: 1 addition & 8 deletions emission/integrationTests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 1 addition & 6 deletions emission/integrationTests/start_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion setup/docker-compose.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ services:
networks:
- emission


networks:
emission:

Expand Down
9 changes: 9 additions & 0 deletions setup/setup_integrationtests.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1e90c65

Please sign in to comment.