Skip to content

Commit

Permalink
Dockerized
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Apr 4, 2023
1 parent c8a8ade commit 052f0dc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/test-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ jobs:
cp .env.example .env
# start the stack
docker compose up --build -d
sleep 10
docker compose \
-f docker-compose.yml \
-f docker-compose.override.yml \
-f docker-compose.tests.yml \
up postgres django --build -d
# deploy static files and migrate database
docker compose run django python manage.py collectstatic --no-input
Expand All @@ -56,15 +59,8 @@ jobs:
- name: Healthcheck
run: wget --no-check-certificate https://localhost/oapif/collections/poles/items

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install and run conformance test
run: |
# Wrapper around official test suite for more convenient handling in CI
pip install -r ./conformance-tests/requirements.txt
python3 -m unittest ./conformance-tests/ogcf.py
- name: Run conformance test
run: docker compose run test_client

- name: Failure logs
if: failure()
Expand Down
4 changes: 4 additions & 0 deletions conformance-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM python:3.9
COPY requirements.txt .
RUN pip3 install -r requirements.txt
CMD ["python3", "-m", "unittest", "./conformance-tests/ogcf.py"]
30 changes: 23 additions & 7 deletions conformance-tests/ogcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@

import requests

test_client_url = "http://localhost:8081/teamengine/rest/suites/ogcapi-features-1.0/run"
api_url = "http://localhost:8000/oapif/"


class ConformanceTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
app_service = "django"
conformance_service = "conformance_suite"
cls.api_url = f"http://{app_service}/oapif/"
cls.test_client_url = f"http://{conformance_service}/teamengine/rest/suites/ogcapi-features-1.0/run"

def test_url(self):
print(f"Trying to access: {self.api_url}")
response = requests.get(self.api_url)
condition = response.status_code == 200

if not condition:
print(response.status_code)
self.assertTrue(condition)

def test_endpoint(self):
params = {"iut": api_url}
params = {"iut": self.api_url}
encoded_params = urlencode(params, quote_via=quote_plus)
url = f"{test_client_url}?{encoded_params}"
url = f"{self.test_client_url}?{encoded_params}"
headers = {"Accept": "application/xml"}
print(f"Validating: {api_url} with {url}")

print(f"Validating: {self.api_url} with {url}")
response = requests.get(url, headers=headers)
print(f"{response.text}")

condition = response.status_code == 200
self.assertTrue(condition)


if __name__ == "__main__":
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
conformance_suite:
image: ogccite/ets-ogcapi-features10
depends_on: [django]

test_client:
build: ${PWD}/conformance-tests
volumes:
- ${PWD}/conformance-tests:/conformance-tests

0 comments on commit 052f0dc

Please sign in to comment.