From 007a54501693fe28c25513ce8391da919638384d Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi (aider) Date: Wed, 5 Feb 2025 12:22:10 +0300 Subject: feat: Add LMDB sample data retrieval API endpoint with tests Signed-off-by: Munyoki Kilyungi --- tests/integration/test_lmdb_sample_data.py | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/integration/test_lmdb_sample_data.py (limited to 'tests/integration/test_lmdb_sample_data.py') 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 -- cgit 1.4.1