Skip to content

Commit

Permalink
Use fixtures in django server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petergarnaes committed Feb 5, 2024
1 parent 6739c36 commit 227a35c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@
from unittest import mock

import django
import pytest
from django.test import Client

from .util import get_test_file_path


@pytest.fixture
@mock.patch.dict(os.environ, {
"DJANGO_SETTINGS_MODULE": "django_.settings",
"PYGEOAPI_CONFIG": get_test_file_path('pygeoapi-test-config.yml'),
"PYGEOAPI_OPENAPI": get_test_file_path('pygeoapi-test-openapi.yml')
})
@mock.patch.object(sys, "path", sys.path + ["./pygeoapi"])
def test_django_landing_page_loads():
def django_():
django.setup()
return django

def test_django_landing_page_loads(django_):
response = Client(SERVER_NAME="localhost").get("/")

assert response.status_code == HTTPStatus.OK
assert response.json()["title"] == "pygeoapi default instance"


def test_django_edr_without_instance_id():
django.setup()

def test_django_edr_without_instance_id(django_):
edr_position_query = ("/collections/icoads-sst/position?coords="
"POINT(12.779895 55.783523)&f=json")
response = Client(SERVER_NAME="localhost").get(edr_position_query)
Expand Down

0 comments on commit 227a35c

Please sign in to comment.