Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Apr 4, 2023
1 parent 2d7a720 commit da052f8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
-f docker-compose.yml \
-f docker-compose.override.yml \
-f docker-compose.tests.yml \
up postgres django --build -d
up postgres django conformance_suite --build -d
# deploy static files and migrate database
docker compose run django python manage.py collectstatic --no-input
Expand Down
2 changes: 1 addition & 1 deletion conformance-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
COPY requirements.txt .
RUN pip3 install -r requirements.txt
CMD ["python3", "-m", "unittest", "./conformance-tests/ogcf.py"]
CMD ["python3", "-m", "unittest", "./conformance-tests/ogcf.py", "-v"]
49 changes: 26 additions & 23 deletions conformance-tests/ogcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@
import requests


def is_200(res: requests.Response) -> bool:
return res.status_code == 200


class ConformanceTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
app_service = "django:8000"
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_api_endpoint(self):
app_address = "django:8000"
cls.api_url = f"http://{app_address}/oapif/"

conformance_suite_address = "conformance_suite:8081"
cls.conformance_suites_url = f"http://{conformance_suite_address}/teamengine/rest/suites"
cls.conformance_ogc_suite_url = f"{cls.conformance_suites_url}/ogcapi-features-1.0/run"

def test_endpoint_django(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_api_endpoint_conformance(self):
params = {"iut": self.api_url}
encoded_params = urlencode(params, quote_via=quote_plus)
url = f"{self.test_client_url}?{encoded_params}"
headers = {"Accept": "application/xml"}

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

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

def test_endpoint_testsuite(self):
print(f"Trying to access: {self.conformance_suites_url}")
response = requests.get(self.conformance_suites_url)
self.assertTrue(is_200(response))

# def test_conformance_api(self):
# params = {"iut": self.api_url}
# encoded_params = urlencode(params, quote_via=quote_plus)
# url = f"{self.test_client_url}?{encoded_params}"
# headers = {"Accept": "application/xml"}
# response = requests.get(url, headers=headers)
# self.assertTrue(is_200(response))


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

test_client:
build: ./conformance-tests
depends_on: [conformance_suite]
volumes:
- ./conformance-tests:/conformance-tests

0 comments on commit da052f8

Please sign in to comment.