diff options
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/conftest.py | 15 | ||||
| -rw-r--r-- | tests/integration/test_lmdb_sample_data.py | 31 |
2 files changed, 42 insertions, 4 deletions
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 8e39726..bdbab09 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,4 +1,5 @@ """Module that holds fixtures for integration tests""" +from pathlib import Path import pytest import MySQLdb @@ -6,19 +7,25 @@ from gn3.app import create_app from gn3.chancy import random_string from gn3.db_utils import parse_db_url, database_connection + @pytest.fixture(scope="session") def client(): """Create a test client fixture for tests""" # Do some setup - app = create_app() - app.config.update({"TESTING": True}) - app.testing = True + app = create_app({ + "TESTING": True, + "LMDB_DATA_PATH": str( + Path(__file__).parent.parent / + Path("test_data/lmdb-test-data") + ), + "AUTH_SERVER_URL": "http://127.0.0.1:8081", + }) yield app.test_client() # Do some teardown/cleanup @pytest.fixture(scope="session") -def db_conn(client): # pylint: disable=[redefined-outer-name] +def db_conn(client): # pylint: disable=[redefined-outer-name] """Create a db connection fixture for tests""" # 01) Generate random string to append to all test db artifacts for the session live_db_uri = client.application.config["SQL_URI"] diff --git a/tests/integration/test_lmdb_sample_data.py b/tests/integration/test_lmdb_sample_data.py new file mode 100644 index 0000000..30a23f4 --- /dev/null +++ b/tests/integration/test_lmdb_sample_data.py @@ -0,0 +1,31 @@ +"""Tests for the LMDB sample data API endpoint""" +import pytest + + +@pytest.mark.unit_test +def test_nonexistent_data(client): + """Test endpoint returns 404 when data doesn't exist""" + response = client.get("/api/lmdb/sample-data/nonexistent/123") + assert response.status_code == 404 + assert response.json["error"] == "No data found for given dataset and trait" + + +@pytest.mark.unit_test +def test_successful_retrieval(client): + """Test successful data retrieval using test LMDB data""" + # Use known test data hash: 7308efbd84b33ad3d69d14b5b1f19ccc + response = client.get("/api/lmdb/sample-data/BXDPublish/10007") + assert response.status_code == 200 + + data = response.json + assert len(data) == 31 + # Verify some known values from the test database + assert data["BXD1"] == 18.700001 + assert data["BXD11"] == 18.9 + + +@pytest.mark.unit_test +def test_invalid_trait_id(client): + """Test endpoint handles invalid trait IDs appropriately""" + response = client.get("/api/lmdb/sample-data/BXDPublish/999999") + assert response.status_code == 404 |
