Skip to content

Commit

Permalink
Bring code in. Tests not passing but shows as passing
Browse files Browse the repository at this point in the history
  • Loading branch information
recalcitrantsupplant committed Aug 14, 2024
1 parent 428ca45 commit 14eaef0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/test_ogc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import asyncio
from pathlib import Path

import pytest
from fastapi.testclient import TestClient
from ogctests.main import run_ogctests
from pyoxigraph.pyoxigraph import Store
from prez.app import assemble_app

from prez.dependencies import get_data_repo
from prez.repositories import PyoxigraphRepo, Repo


@pytest.fixture(scope="session")
def test_store() -> Store:
# Create a new pyoxigraph Store
store = Store()

file = Path("../test_data/spaceprez.ttl")
store.load(file.read_bytes(), "text/turtle")

return store


@pytest.fixture(scope="session")
def test_repo(test_store: Store) -> Repo:
# Create a PyoxigraphQuerySender using the test_store
return PyoxigraphRepo(test_store)


@pytest.fixture(scope="session")
def client(test_repo: Repo) -> TestClient:
# Override the dependency to use the test_repo
def override_get_data_repo():
return test_repo

app = assemble_app()

app.dependency_overrides[get_data_repo] = override_get_data_repo

with TestClient(app, backend_options={'loop_factory': asyncio.new_event_loop}) as c:
yield c

# Remove the override to ensure subsequent tests are unaffected
app.dependency_overrides.clear()


def test_features_core(client: TestClient):
scope = "features/core"
run_ogctests(scope, test_client=client)

0 comments on commit 14eaef0

Please sign in to comment.