From 0ad2c8e0d996d58a33c22ca4557657f67aaeed69 Mon Sep 17 00:00:00 2001 From: francastell Date: Wed, 13 Mar 2024 16:56:58 -0400 Subject: [PATCH 1/3] G3-192 species endpoint --- poetry.lock | 62 ++++++++-------- pyproject.toml | 2 +- src/geneweaver/api/controller/api.py | 3 +- src/geneweaver/api/controller/species.py | 24 +++++++ src/geneweaver/api/services/species.py | 29 ++++++++ tests/controllers/test_species.py | 43 +++++++++++ tests/data/__init__.py | 13 ++++ tests/data/species.json | 92 ++++++++++++++++++++++++ tests/services/test_species.py | 82 +++++++++++++++++++++ 9 files changed, 317 insertions(+), 33 deletions(-) create mode 100644 src/geneweaver/api/controller/species.py create mode 100644 src/geneweaver/api/services/species.py create mode 100644 tests/controllers/test_species.py create mode 100644 tests/data/species.json create mode 100644 tests/services/test_species.py diff --git a/poetry.lock b/poetry.lock index 594c348..37d9a20 100644 --- a/poetry.lock +++ b/poetry.lock @@ -785,38 +785,38 @@ files = [ [[package]] name = "mypy" -version = "1.8.0" +version = "1.9.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:485a8942f671120f76afffff70f259e1cd0f0cfe08f81c05d8816d958d4577d3"}, - {file = "mypy-1.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:df9824ac11deaf007443e7ed2a4a26bebff98d2bc43c6da21b2b64185da011c4"}, - {file = "mypy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2afecd6354bbfb6e0160f4e4ad9ba6e4e003b767dd80d85516e71f2e955ab50d"}, - {file = "mypy-1.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8963b83d53ee733a6e4196954502b33567ad07dfd74851f32be18eb932fb1cb9"}, - {file = "mypy-1.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:e46f44b54ebddbeedbd3d5b289a893219065ef805d95094d16a0af6630f5d410"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:855fe27b80375e5c5878492f0729540db47b186509c98dae341254c8f45f42ae"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4c886c6cce2d070bd7df4ec4a05a13ee20c0aa60cb587e8d1265b6c03cf91da3"}, - {file = "mypy-1.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d19c413b3c07cbecf1f991e2221746b0d2a9410b59cb3f4fb9557f0365a1a817"}, - {file = "mypy-1.8.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9261ed810972061388918c83c3f5cd46079d875026ba97380f3e3978a72f503d"}, - {file = "mypy-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:51720c776d148bad2372ca21ca29256ed483aa9a4cdefefcef49006dff2a6835"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:52825b01f5c4c1c4eb0db253ec09c7aa17e1a7304d247c48b6f3599ef40db8bd"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f5ac9a4eeb1ec0f1ccdc6f326bcdb464de5f80eb07fb38b5ddd7b0de6bc61e55"}, - {file = "mypy-1.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afe3fe972c645b4632c563d3f3eff1cdca2fa058f730df2b93a35e3b0c538218"}, - {file = "mypy-1.8.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:42c6680d256ab35637ef88891c6bd02514ccb7e1122133ac96055ff458f93fc3"}, - {file = "mypy-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:720a5ca70e136b675af3af63db533c1c8c9181314d207568bbe79051f122669e"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:028cf9f2cae89e202d7b6593cd98db6759379f17a319b5faf4f9978d7084cdc6"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4e6d97288757e1ddba10dd9549ac27982e3e74a49d8d0179fc14d4365c7add66"}, - {file = "mypy-1.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f1478736fcebb90f97e40aff11a5f253af890c845ee0c850fe80aa060a267c6"}, - {file = "mypy-1.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42419861b43e6962a649068a61f4a4839205a3ef525b858377a960b9e2de6e0d"}, - {file = "mypy-1.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:2b5b6c721bd4aabaadead3a5e6fa85c11c6c795e0c81a7215776ef8afc66de02"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5c1538c38584029352878a0466f03a8ee7547d7bd9f641f57a0f3017a7c905b8"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ef4be7baf08a203170f29e89d79064463b7fc7a0908b9d0d5114e8009c3a259"}, - {file = "mypy-1.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7178def594014aa6c35a8ff411cf37d682f428b3b5617ca79029d8ae72f5402b"}, - {file = "mypy-1.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ab3c84fa13c04aeeeabb2a7f67a25ef5d77ac9d6486ff33ded762ef353aa5592"}, - {file = "mypy-1.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:99b00bc72855812a60d253420d8a2eae839b0afa4938f09f4d2aa9bb4654263a"}, - {file = "mypy-1.8.0-py3-none-any.whl", hash = "sha256:538fd81bb5e430cc1381a443971c0475582ff9f434c16cd46d2c66763ce85d9d"}, - {file = "mypy-1.8.0.tar.gz", hash = "sha256:6ff8b244d7085a0b425b56d327b480c3b29cafbd2eff27316a004f9a7391ae07"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, + {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, + {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, + {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, + {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, + {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, + {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, + {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, + {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, + {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, + {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, + {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, + {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, + {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, + {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, + {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, + {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, + {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, ] [package.dependencies] @@ -953,13 +953,13 @@ files = [ [[package]] name = "packaging" -version = "23.2" +version = "24.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.7" files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, + {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, + {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 2f44424..807ee10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-api" -version = "0.3.0" +version = "0.3.0a01" description = "The Geneweaver API" authors = [ "Alexander Berger ", diff --git a/src/geneweaver/api/controller/api.py b/src/geneweaver/api/controller/api.py index 0385bf7..808d4b4 100644 --- a/src/geneweaver/api/controller/api.py +++ b/src/geneweaver/api/controller/api.py @@ -6,7 +6,7 @@ from fastapi import APIRouter, FastAPI, Security from geneweaver.api import __version__ from geneweaver.api import dependencies as deps -from geneweaver.api.controller import genes, genesets, publications +from geneweaver.api.controller import genes, genesets, publications, species from geneweaver.api.core.config import settings app = FastAPI( @@ -28,5 +28,6 @@ api_router.include_router(genesets.router) api_router.include_router(genes.router) api_router.include_router(publications.router) +api_router.include_router(species.router) app.include_router(api_router, prefix=settings.API_PREFIX) diff --git a/src/geneweaver/api/controller/species.py b/src/geneweaver/api/controller/species.py new file mode 100644 index 0000000..dd296bb --- /dev/null +++ b/src/geneweaver/api/controller/species.py @@ -0,0 +1,24 @@ +"""Endpoints related to species.""" +from typing import Optional + +from fastapi import APIRouter, Depends, Query +from geneweaver.api import dependencies as deps +from geneweaver.api.services import species as species_service +from geneweaver.core.enum import GeneIdentifier +from typing_extensions import Annotated + +router = APIRouter(prefix="/species", tags=["species"]) + + +@router.get("/") +def get_species( + cursor: Optional[deps.Cursor] = Depends(deps.cursor), + taxonomy_id: Annotated[ + Optional[int], Query(format="int64", minimum=0, maxiumum=9223372036854775807) + ] = None, + gene_id_type: Optional[GeneIdentifier] = None, +) -> dict: + """Get species.""" + response = species_service.get_species(cursor, taxonomy_id, gene_id_type) + + return response diff --git a/src/geneweaver/api/services/species.py b/src/geneweaver/api/services/species.py new file mode 100644 index 0000000..d20c80d --- /dev/null +++ b/src/geneweaver/api/services/species.py @@ -0,0 +1,29 @@ +"""Service functions for Species.""" + +from typing import Optional + +from fastapi.logger import logger +from geneweaver.core.enum import GeneIdentifier +from geneweaver.db import species as db_species +from psycopg import Cursor + + +def get_species( + cursor: Cursor, + taxonomy_id: Optional[int] = None, + gene_id_type: Optional[GeneIdentifier] = None, +) -> dict: + """Get species from DB. + + @param cursor: DB cursor + @param taxonomy_id: + @param gene_id_type: + @return: dictionary response (species). + """ + try: + species = db_species.get(cursor, taxonomy_id, gene_id_type) + return {"species": species} + + except Exception as err: + logger.error(err) + raise err diff --git a/tests/controllers/test_species.py b/tests/controllers/test_species.py new file mode 100644 index 0000000..bf8ba4e --- /dev/null +++ b/tests/controllers/test_species.py @@ -0,0 +1,43 @@ +"""Tests for species API.""" +from unittest.mock import patch + +from tests.data import test_species_data + +species_no_params = test_species_data.get("species_no_params") +species_by_taxonomy_id_10090 = test_species_data.get("species_by_taxonomy_id_10090") +species_by_gene_id_type_flybase = test_species_data.get( + "species_by_gene_id_type_flybase" +) + + +@patch("geneweaver.api.services.species.get_species") +def test_valid_species_url_req(mock_species_service_call, client): + """Test valid url request to get species.""" + mock_species_service_call.return_value = species_no_params + + response = client.get(url="/api/species") + + assert response.status_code == 200 + assert response.json() == species_no_params + + +@patch("geneweaver.api.services.species.get_species") +def test_species_url_taxonomy_req(mock_species_service_call, client): + """Test valid url request to get species.""" + mock_species_service_call.return_value = species_by_taxonomy_id_10090 + + response = client.get(url="/api/species?taxonomy_id=10090") + + assert response.status_code == 200 + assert response.json() == species_by_taxonomy_id_10090 + + +@patch("geneweaver.api.services.species.get_species") +def test_valid_species_url_gene_id_type_req(mock_species_service_call, client): + """Test valid url request to get species.""" + mock_species_service_call.return_value = species_by_gene_id_type_flybase + + response = client.get(url="/api/species?gene_id_type=14") + + assert response.status_code == 200 + assert response.json() == species_by_gene_id_type_flybase diff --git a/tests/data/__init__.py b/tests/data/__init__.py index f9388c7..b6ce854 100644 --- a/tests/data/__init__.py +++ b/tests/data/__init__.py @@ -24,6 +24,7 @@ "tests.data", "security_jwt_RS256_keys.json" ) +species_json = importlib.resources.read_text("tests.data", "species.json") ## laod and returns JSON string as a dictionary @@ -93,3 +94,15 @@ "test_private_key": json.loads(jwt_test_keys_json).get("private_key"), "test_public_key": json.loads(jwt_test_keys_json).get("public_key"), } + + +## Species test data +test_species_data = { + "species_no_params": json.loads(species_json).get("species_no_parameters"), + "species_by_taxonomy_id_10090": json.loads(species_json).get( + "species_by_taxonomy_id_10090" + ), + "species_by_gene_id_type_flybase": json.loads(species_json).get( + "species_by_gene_id_type_flybase" + ), +} diff --git a/tests/data/species.json b/tests/data/species.json new file mode 100644 index 0000000..bab8f4f --- /dev/null +++ b/tests/data/species.json @@ -0,0 +1,92 @@ +{ + "species_no_parameters": { + "species": [ + { + "id": 0, + "name": "", + "taxonomic_id": 0, + "reference_gene_identifier": null + }, + { + "id": 3, + "name": "Rattus norvegicus", + "taxonomic_id": 10116, + "reference_gene_identifier": 12 + }, + { + "id": 4, + "name": "Danio rerio", + "taxonomic_id": 7955, + "reference_gene_identifier": 13 + }, + { + "id": 10, + "name": "Gallus gallus", + "taxonomic_id": 9031, + "reference_gene_identifier": 20 + }, + { + "id": 1, + "name": "Mus musculus", + "taxonomic_id": 10090, + "reference_gene_identifier": 10 + }, + { + "id": 5, + "name": "Drosophila melanogaster", + "taxonomic_id": 7227, + "reference_gene_identifier": 14 + }, + { + "id": 11, + "name": "Canis familiaris", + "taxonomic_id": 9615, + "reference_gene_identifier": 1 + }, + { + "id": 2, + "name": "Homo sapiens", + "taxonomic_id": 9606, + "reference_gene_identifier": 11 + }, + { + "id": 8, + "name": "Caenorhabditis elegans", + "taxonomic_id": 6239, + "reference_gene_identifier": 15 + }, + { + "id": 9, + "name": "Saccharomyces cerevisiae", + "taxonomic_id": 559292, + "reference_gene_identifier": 16 + }, + { + "id": 6, + "name": "Macaca mulatta", + "taxonomic_id": 9544, + "reference_gene_identifier": 1 + } + ] + }, + "species_by_taxonomy_id_10090": { + "species": [ + { + "id": 1, + "name": "Mus musculus", + "taxonomic_id": 10090, + "reference_gene_identifier": 10 + } + ] + }, + "species_by_gene_id_type_flybase": { + "species": [ + { + "id": 5, + "name": "Drosophila melanogaster", + "taxonomic_id": 7227, + "reference_gene_identifier": 14 + } + ] + } +} \ No newline at end of file diff --git a/tests/services/test_species.py b/tests/services/test_species.py new file mode 100644 index 0000000..6fdca6c --- /dev/null +++ b/tests/services/test_species.py @@ -0,0 +1,82 @@ +"""Tests for publications Service.""" + +from unittest.mock import patch + +import pytest +from geneweaver.api.services import species as species_service +from geneweaver.core.enum import GeneIdentifier + +from tests.data import test_species_data + +species_no_params = test_species_data.get("species_no_params") +species_by_taxonomy_id_10090 = test_species_data.get("species_by_taxonomy_id_10090") +species_by_gene_id_type_flybase = test_species_data.get( + "species_by_gene_id_type_flybase" +) + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species(mock_db_species): + """Test get species no paramaters.""" + mock_db_species.get.return_value = species_no_params + + response = species_service.get_species(None) + + assert response.get("species") == species_no_params + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species_by_taxonomy_id(mock_db_species): + """Test speccies by taxonomy id.""" + mock_db_species.get.return_value = species_by_taxonomy_id_10090 + + response = species_service.get_species(None, taxonomy_id=10090) + + assert response.get("species") == species_by_taxonomy_id_10090 + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species_by_gene_id_type(mock_db_species): + """Test speccies by taxonomy id.""" + mock_db_species.get.return_value = species_by_gene_id_type_flybase + + response = species_service.get_species(None, gene_id_type=GeneIdentifier("FlyBase")) + + assert response.get("species") == species_by_gene_id_type_flybase + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species_by_gene_id_type_and_taxonomy(mock_db_species): + """Test speccies by taxonomy id.""" + mock_db_species.get.return_value = species_by_gene_id_type_flybase + + response = species_service.get_species( + None, gene_id_type=GeneIdentifier("FlyBase"), taxonomy_id=7227 + ) + + assert response.get("species") == species_by_gene_id_type_flybase + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species_with_error(mock_db_species): + """Test error in DB call.""" + mock_db_species.get.side_effect = Exception("ERROR") + + with pytest.raises(expected_exception=Exception): + species_service.get(None) + + +@patch("geneweaver.api.services.species.db_species") +def test_get_species_invalid_params(mock_db_species): + """Test speccies by taxonomy id.""" + mock_db_species.get.return_value = species_no_params + + # with pytest.raises(expected_exception=Exception): + + response = species_service.get_species( + None, taxonomy_id="qweqw", gene_id_type="asdasd" + ) + + # with pytest.raises(expected_exception=TypeError): + + assert response.get("species") == species_no_params From fbcb259ae275777a81ca1747d95fd75f7683ce6f Mon Sep 17 00:00:00 2001 From: francastell Date: Fri, 15 Mar 2024 15:20:24 -0400 Subject: [PATCH 2/3] db version update, udpates to api response and tests --- poetry.lock | 114 +++++++++++------------ pyproject.toml | 2 +- src/geneweaver/api/controller/species.py | 4 +- src/geneweaver/api/services/species.py | 13 ++- tests/controllers/test_species.py | 2 +- tests/data/__init__.py | 17 +++- tests/data/species.json | 24 ++--- tests/services/test_species.py | 34 +++---- 8 files changed, 110 insertions(+), 100 deletions(-) diff --git a/poetry.lock b/poetry.lock index 37d9a20..2c89b22 100644 --- a/poetry.lock +++ b/poetry.lock @@ -269,63 +269,63 @@ files = [ [[package]] name = "coverage" -version = "7.4.3" +version = "7.4.4" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.4.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8580b827d4746d47294c0e0b92854c85a92c2227927433998f0d3320ae8a71b6"}, - {file = "coverage-7.4.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:718187eeb9849fc6cc23e0d9b092bc2348821c5e1a901c9f8975df0bc785bfd4"}, - {file = "coverage-7.4.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:767b35c3a246bcb55b8044fd3a43b8cd553dd1f9f2c1eeb87a302b1f8daa0524"}, - {file = "coverage-7.4.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae7f19afe0cce50039e2c782bff379c7e347cba335429678450b8fe81c4ef96d"}, - {file = "coverage-7.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba3a8aaed13770e970b3df46980cb068d1c24af1a1968b7818b69af8c4347efb"}, - {file = "coverage-7.4.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ee866acc0861caebb4f2ab79f0b94dbfbdbfadc19f82e6e9c93930f74e11d7a0"}, - {file = "coverage-7.4.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:506edb1dd49e13a2d4cac6a5173317b82a23c9d6e8df63efb4f0380de0fbccbc"}, - {file = "coverage-7.4.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd6545d97c98a192c5ac995d21c894b581f1fd14cf389be90724d21808b657e2"}, - {file = "coverage-7.4.3-cp310-cp310-win32.whl", hash = "sha256:f6a09b360d67e589236a44f0c39218a8efba2593b6abdccc300a8862cffc2f94"}, - {file = "coverage-7.4.3-cp310-cp310-win_amd64.whl", hash = "sha256:18d90523ce7553dd0b7e23cbb28865db23cddfd683a38fb224115f7826de78d0"}, - {file = "coverage-7.4.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cbbe5e739d45a52f3200a771c6d2c7acf89eb2524890a4a3aa1a7fa0695d2a47"}, - {file = "coverage-7.4.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:489763b2d037b164846ebac0cbd368b8a4ca56385c4090807ff9fad817de4113"}, - {file = "coverage-7.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:451f433ad901b3bb00184d83fd83d135fb682d780b38af7944c9faeecb1e0bfe"}, - {file = "coverage-7.4.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fcc66e222cf4c719fe7722a403888b1f5e1682d1679bd780e2b26c18bb648cdc"}, - {file = "coverage-7.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b3ec74cfef2d985e145baae90d9b1b32f85e1741b04cd967aaf9cfa84c1334f3"}, - {file = "coverage-7.4.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:abbbd8093c5229c72d4c2926afaee0e6e3140de69d5dcd918b2921f2f0c8baba"}, - {file = "coverage-7.4.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:35eb581efdacf7b7422af677b92170da4ef34500467381e805944a3201df2079"}, - {file = "coverage-7.4.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8249b1c7334be8f8c3abcaaa996e1e4927b0e5a23b65f5bf6cfe3180d8ca7840"}, - {file = "coverage-7.4.3-cp311-cp311-win32.whl", hash = "sha256:cf30900aa1ba595312ae41978b95e256e419d8a823af79ce670835409fc02ad3"}, - {file = "coverage-7.4.3-cp311-cp311-win_amd64.whl", hash = "sha256:18c7320695c949de11a351742ee001849912fd57e62a706d83dfc1581897fa2e"}, - {file = "coverage-7.4.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b51bfc348925e92a9bd9b2e48dad13431b57011fd1038f08316e6bf1df107d10"}, - {file = "coverage-7.4.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d6cdecaedea1ea9e033d8adf6a0ab11107b49571bbb9737175444cea6eb72328"}, - {file = "coverage-7.4.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b2eccb883368f9e972e216c7b4c7c06cabda925b5f06dde0650281cb7666a30"}, - {file = "coverage-7.4.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6c00cdc8fa4e50e1cc1f941a7f2e3e0f26cb2a1233c9696f26963ff58445bac7"}, - {file = "coverage-7.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b9a4a8dd3dcf4cbd3165737358e4d7dfbd9d59902ad11e3b15eebb6393b0446e"}, - {file = "coverage-7.4.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:062b0a75d9261e2f9c6d071753f7eef0fc9caf3a2c82d36d76667ba7b6470003"}, - {file = "coverage-7.4.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:ebe7c9e67a2d15fa97b77ea6571ce5e1e1f6b0db71d1d5e96f8d2bf134303c1d"}, - {file = "coverage-7.4.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:c0a120238dd71c68484f02562f6d446d736adcc6ca0993712289b102705a9a3a"}, - {file = "coverage-7.4.3-cp312-cp312-win32.whl", hash = "sha256:37389611ba54fd6d278fde86eb2c013c8e50232e38f5c68235d09d0a3f8aa352"}, - {file = "coverage-7.4.3-cp312-cp312-win_amd64.whl", hash = "sha256:d25b937a5d9ffa857d41be042b4238dd61db888533b53bc76dc082cb5a15e914"}, - {file = "coverage-7.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:28ca2098939eabab044ad68850aac8f8db6bf0b29bc7f2887d05889b17346454"}, - {file = "coverage-7.4.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:280459f0a03cecbe8800786cdc23067a8fc64c0bd51dc614008d9c36e1659d7e"}, - {file = "coverage-7.4.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c0cdedd3500e0511eac1517bf560149764b7d8e65cb800d8bf1c63ebf39edd2"}, - {file = "coverage-7.4.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9a9babb9466fe1da12417a4aed923e90124a534736de6201794a3aea9d98484e"}, - {file = "coverage-7.4.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dec9de46a33cf2dd87a5254af095a409ea3bf952d85ad339751e7de6d962cde6"}, - {file = "coverage-7.4.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:16bae383a9cc5abab9bb05c10a3e5a52e0a788325dc9ba8499e821885928968c"}, - {file = "coverage-7.4.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:2c854ce44e1ee31bda4e318af1dbcfc929026d12c5ed030095ad98197eeeaed0"}, - {file = "coverage-7.4.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ce8c50520f57ec57aa21a63ea4f325c7b657386b3f02ccaedeccf9ebe27686e1"}, - {file = "coverage-7.4.3-cp38-cp38-win32.whl", hash = "sha256:708a3369dcf055c00ddeeaa2b20f0dd1ce664eeabde6623e516c5228b753654f"}, - {file = "coverage-7.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:1bf25fbca0c8d121a3e92a2a0555c7e5bc981aee5c3fdaf4bb7809f410f696b9"}, - {file = "coverage-7.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3b253094dbe1b431d3a4ac2f053b6d7ede2664ac559705a704f621742e034f1f"}, - {file = "coverage-7.4.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:77fbfc5720cceac9c200054b9fab50cb2a7d79660609200ab83f5db96162d20c"}, - {file = "coverage-7.4.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6679060424faa9c11808598504c3ab472de4531c571ab2befa32f4971835788e"}, - {file = "coverage-7.4.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4af154d617c875b52651dd8dd17a31270c495082f3d55f6128e7629658d63765"}, - {file = "coverage-7.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8640f1fde5e1b8e3439fe482cdc2b0bb6c329f4bb161927c28d2e8879c6029ee"}, - {file = "coverage-7.4.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:69b9f6f66c0af29642e73a520b6fed25ff9fd69a25975ebe6acb297234eda501"}, - {file = "coverage-7.4.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0842571634f39016a6c03e9d4aba502be652a6e4455fadb73cd3a3a49173e38f"}, - {file = "coverage-7.4.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a78ed23b08e8ab524551f52953a8a05d61c3a760781762aac49f8de6eede8c45"}, - {file = "coverage-7.4.3-cp39-cp39-win32.whl", hash = "sha256:c0524de3ff096e15fcbfe8f056fdb4ea0bf497d584454f344d59fce069d3e6e9"}, - {file = "coverage-7.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:0209a6369ccce576b43bb227dc8322d8ef9e323d089c6f3f26a597b09cb4d2aa"}, - {file = "coverage-7.4.3-pp38.pp39.pp310-none-any.whl", hash = "sha256:7cbde573904625509a3f37b6fecea974e363460b556a627c60dc2f47e2fffa51"}, - {file = "coverage-7.4.3.tar.gz", hash = "sha256:276f6077a5c61447a48d133ed13e759c09e62aff0dc84274a68dc18660104d52"}, + {file = "coverage-7.4.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0be5efd5127542ef31f165de269f77560d6cdef525fffa446de6f7e9186cfb2"}, + {file = "coverage-7.4.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ccd341521be3d1b3daeb41960ae94a5e87abe2f46f17224ba5d6f2b8398016cf"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fa497a8ab37784fbb20ab699c246053ac294d13fc7eb40ec007a5043ec91f8"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b1a93009cb80730c9bca5d6d4665494b725b6e8e157c1cb7f2db5b4b122ea562"}, + {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:690db6517f09336559dc0b5f55342df62370a48f5469fabf502db2c6d1cffcd2"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:09c3255458533cb76ef55da8cc49ffab9e33f083739c8bd4f58e79fecfe288f7"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:8ce1415194b4a6bd0cdcc3a1dfbf58b63f910dcb7330fe15bdff542c56949f87"}, + {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b91cbc4b195444e7e258ba27ac33769c41b94967919f10037e6355e998af255c"}, + {file = "coverage-7.4.4-cp310-cp310-win32.whl", hash = "sha256:598825b51b81c808cb6f078dcb972f96af96b078faa47af7dfcdf282835baa8d"}, + {file = "coverage-7.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:09ef9199ed6653989ebbcaacc9b62b514bb63ea2f90256e71fea3ed74bd8ff6f"}, + {file = "coverage-7.4.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f9f50e7ef2a71e2fae92774c99170eb8304e3fdf9c8c3c7ae9bab3e7229c5cf"}, + {file = "coverage-7.4.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:623512f8ba53c422fcfb2ce68362c97945095b864cda94a92edbaf5994201083"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0513b9508b93da4e1716744ef6ebc507aff016ba115ffe8ecff744d1322a7b63"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40209e141059b9370a2657c9b15607815359ab3ef9918f0196b6fccce8d3230f"}, + {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8a2b2b78c78293782fd3767d53e6474582f62443d0504b1554370bde86cc8227"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:73bfb9c09951125d06ee473bed216e2c3742f530fc5acc1383883125de76d9cd"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:1f384c3cc76aeedce208643697fb3e8437604b512255de6d18dae3f27655a384"}, + {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:54eb8d1bf7cacfbf2a3186019bcf01d11c666bd495ed18717162f7eb1e9dd00b"}, + {file = "coverage-7.4.4-cp311-cp311-win32.whl", hash = "sha256:cac99918c7bba15302a2d81f0312c08054a3359eaa1929c7e4b26ebe41e9b286"}, + {file = "coverage-7.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:b14706df8b2de49869ae03a5ccbc211f4041750cd4a66f698df89d44f4bd30ec"}, + {file = "coverage-7.4.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:201bef2eea65e0e9c56343115ba3814e896afe6d36ffd37bab783261db430f76"}, + {file = "coverage-7.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:41c9c5f3de16b903b610d09650e5e27adbfa7f500302718c9ffd1c12cf9d6818"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d898fe162d26929b5960e4e138651f7427048e72c853607f2b200909794ed978"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ea79bb50e805cd6ac058dfa3b5c8f6c040cb87fe83de10845857f5535d1db70"}, + {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce4b94265ca988c3f8e479e741693d143026632672e3ff924f25fab50518dd51"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:00838a35b882694afda09f85e469c96367daa3f3f2b097d846a7216993d37f4c"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fdfafb32984684eb03c2d83e1e51f64f0906b11e64482df3c5db936ce3839d48"}, + {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:69eb372f7e2ece89f14751fbcbe470295d73ed41ecd37ca36ed2eb47512a6ab9"}, + {file = "coverage-7.4.4-cp312-cp312-win32.whl", hash = "sha256:137eb07173141545e07403cca94ab625cc1cc6bc4c1e97b6e3846270e7e1fea0"}, + {file = "coverage-7.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:d71eec7d83298f1af3326ce0ff1d0ea83c7cb98f72b577097f9083b20bdaf05e"}, + {file = "coverage-7.4.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d5ae728ff3b5401cc320d792866987e7e7e880e6ebd24433b70a33b643bb0384"}, + {file = "coverage-7.4.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:cc4f1358cb0c78edef3ed237ef2c86056206bb8d9140e73b6b89fbcfcbdd40e1"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8130a2aa2acb8788e0b56938786c33c7c98562697bf9f4c7d6e8e5e3a0501e4a"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cf271892d13e43bc2b51e6908ec9a6a5094a4df1d8af0bfc360088ee6c684409"}, + {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a4cdc86d54b5da0df6d3d3a2f0b710949286094c3a6700c21e9015932b81447e"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ae71e7ddb7a413dd60052e90528f2f65270aad4b509563af6d03d53e979feafd"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:38dd60d7bf242c4ed5b38e094baf6401faa114fc09e9e6632374388a404f98e7"}, + {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa5b1c1bfc28384f1f53b69a023d789f72b2e0ab1b3787aae16992a7ca21056c"}, + {file = "coverage-7.4.4-cp38-cp38-win32.whl", hash = "sha256:dfa8fe35a0bb90382837b238fff375de15f0dcdb9ae68ff85f7a63649c98527e"}, + {file = "coverage-7.4.4-cp38-cp38-win_amd64.whl", hash = "sha256:b2991665420a803495e0b90a79233c1433d6ed77ef282e8e152a324bbbc5e0c8"}, + {file = "coverage-7.4.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3b799445b9f7ee8bf299cfaed6f5b226c0037b74886a4e11515e569b36fe310d"}, + {file = "coverage-7.4.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b4d33f418f46362995f1e9d4f3a35a1b6322cb959c31d88ae56b0298e1c22357"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aadacf9a2f407a4688d700e4ebab33a7e2e408f2ca04dbf4aef17585389eff3e"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c95949560050d04d46b919301826525597f07b33beba6187d04fa64d47ac82e"}, + {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ff7687ca3d7028d8a5f0ebae95a6e4827c5616b31a4ee1192bdfde697db110d4"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5fc1de20b2d4a061b3df27ab9b7c7111e9a710f10dc2b84d33a4ab25065994ec"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c74880fc64d4958159fbd537a091d2a585448a8f8508bf248d72112723974cbd"}, + {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:742a76a12aa45b44d236815d282b03cfb1de3b4323f3e4ec933acfae08e54ade"}, + {file = "coverage-7.4.4-cp39-cp39-win32.whl", hash = "sha256:d89d7b2974cae412400e88f35d86af72208e1ede1a541954af5d944a8ba46c57"}, + {file = "coverage-7.4.4-cp39-cp39-win_amd64.whl", hash = "sha256:9ca28a302acb19b6af89e90f33ee3e1906961f94b54ea37de6737b7ca9d8827c"}, + {file = "coverage-7.4.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:b2c5edc4ac10a7ef6605a966c58929ec6c1bd0917fb8c15cb3363f65aa40e677"}, + {file = "coverage-7.4.4.tar.gz", hash = "sha256:c901df83d097649e257e803be22592aedfd5182f07b3cc87d640bbb9afd50f49"}, ] [package.dependencies] @@ -513,13 +513,13 @@ pydantic = {version = ">=1.10.7,<2.0.0", extras = ["dotenv"]} [[package]] name = "geneweaver-db" -version = "0.3.0a11" +version = "0.3.0a12" description = "Database Interaction Services for GeneWeaver" optional = false python-versions = ">=3.9,<4.0" files = [ - {file = "geneweaver_db-0.3.0a11-py3-none-any.whl", hash = "sha256:88e486fd5490884e91e99e0354ff899c21d5e18f60a547d700f8d077e28ee3f5"}, - {file = "geneweaver_db-0.3.0a11.tar.gz", hash = "sha256:7c1875414ece157e03fe284b537a007ff69a4384253e6432289b85124f05b562"}, + {file = "geneweaver_db-0.3.0a12-py3-none-any.whl", hash = "sha256:523e8c8f24863ab83f0953e9ee906b7462610746cdee53dc21ca16dc4409a679"}, + {file = "geneweaver_db-0.3.0a12.tar.gz", hash = "sha256:4af5b12cf00ac54d7821bf90c9e668382b012a4db299fb2f7b0fd45be83030da"}, ] [package.dependencies] @@ -1905,4 +1905,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "53c418b2b7cd7f82dc46c6ad988aedb90d4c3a5941a89a4db69472c72164b6b4" +content-hash = "73b9bbc2787a3db43f5a067aa5f4d4098f3401446c857543053d748ef7fab760" diff --git a/pyproject.toml b/pyproject.toml index 807ee10..0c04a2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ python = "^3.9" geneweaver-core = "^0.9.0a1" fastapi = {extras = ["all"], version = "^0.99.1"} uvicorn = {extras = ["standard"], version = "^0.24.0"} -geneweaver-db = "^0.3.0a11" +geneweaver-db = "^0.3.0a12" psycopg-pool = "^3.1.7" requests = "^2.31.0" python-jose = {extras = ["cryptography"], version = "^3.3.0"} diff --git a/src/geneweaver/api/controller/species.py b/src/geneweaver/api/controller/species.py index dd296bb..ec45a9f 100644 --- a/src/geneweaver/api/controller/species.py +++ b/src/geneweaver/api/controller/species.py @@ -16,9 +16,9 @@ def get_species( taxonomy_id: Annotated[ Optional[int], Query(format="int64", minimum=0, maxiumum=9223372036854775807) ] = None, - gene_id_type: Optional[GeneIdentifier] = None, + reference_gene_id_type: Optional[GeneIdentifier] = None, ) -> dict: """Get species.""" - response = species_service.get_species(cursor, taxonomy_id, gene_id_type) + response = species_service.get_species(cursor, taxonomy_id, reference_gene_id_type) return response diff --git a/src/geneweaver/api/services/species.py b/src/geneweaver/api/services/species.py index d20c80d..a619396 100644 --- a/src/geneweaver/api/services/species.py +++ b/src/geneweaver/api/services/species.py @@ -11,17 +11,24 @@ def get_species( cursor: Cursor, taxonomy_id: Optional[int] = None, - gene_id_type: Optional[GeneIdentifier] = None, + reference_gene_id_type: Optional[GeneIdentifier] = None, ) -> dict: """Get species from DB. @param cursor: DB cursor @param taxonomy_id: - @param gene_id_type: + @param reference_gene_id_type: @return: dictionary response (species). """ try: - species = db_species.get(cursor, taxonomy_id, gene_id_type) + species = db_species.get(cursor, taxonomy_id, reference_gene_id_type) + for species_record in species: + ref_gene_id_type = species_record.get("reference_gene_identifier", None) + if ref_gene_id_type: + species_record["reference_gene_identifier"] = GeneIdentifier( + ref_gene_id_type + ) + return {"species": species} except Exception as err: diff --git a/tests/controllers/test_species.py b/tests/controllers/test_species.py index bf8ba4e..05ee2ee 100644 --- a/tests/controllers/test_species.py +++ b/tests/controllers/test_species.py @@ -3,7 +3,7 @@ from tests.data import test_species_data -species_no_params = test_species_data.get("species_no_params") +species_no_params = test_species_data.get("species_no_parameters") species_by_taxonomy_id_10090 = test_species_data.get("species_by_taxonomy_id_10090") species_by_gene_id_type_flybase = test_species_data.get( "species_by_gene_id_type_flybase" diff --git a/tests/data/__init__.py b/tests/data/__init__.py index b6ce854..77d37ca 100644 --- a/tests/data/__init__.py +++ b/tests/data/__init__.py @@ -3,6 +3,8 @@ import importlib.resources import json +from geneweaver.core.enum import GeneIdentifier + ## Load test data # Opening JSON files geneset_response_json = importlib.resources.read_text( @@ -98,7 +100,7 @@ ## Species test data test_species_data = { - "species_no_params": json.loads(species_json).get("species_no_parameters"), + "species_no_parameters": json.loads(species_json).get("species_no_parameters"), "species_by_taxonomy_id_10090": json.loads(species_json).get( "species_by_taxonomy_id_10090" ), @@ -106,3 +108,16 @@ "species_by_gene_id_type_flybase" ), } + + +def get_species_db_resp(species_data: dict) -> dict: + """ " get species data as returned by DB.""" + species = species_data.get("species") + for species_record in species: + ref_gene_id_type = species_record.get("reference_gene_identifier", None) + if ref_gene_id_type: + species_record["reference_gene_identifier"] = GeneIdentifier( + ref_gene_id_type + ).as_int() + + return species diff --git a/tests/data/species.json b/tests/data/species.json index bab8f4f..727d3f3 100644 --- a/tests/data/species.json +++ b/tests/data/species.json @@ -11,61 +11,61 @@ "id": 3, "name": "Rattus norvegicus", "taxonomic_id": 10116, - "reference_gene_identifier": 12 + "reference_gene_identifier": "RGD" }, { "id": 4, "name": "Danio rerio", "taxonomic_id": 7955, - "reference_gene_identifier": 13 + "reference_gene_identifier": "ZFIN" }, { "id": 10, "name": "Gallus gallus", "taxonomic_id": 9031, - "reference_gene_identifier": 20 + "reference_gene_identifier": "CGNC" }, { "id": 1, "name": "Mus musculus", "taxonomic_id": 10090, - "reference_gene_identifier": 10 + "reference_gene_identifier": "MGI" }, { "id": 5, "name": "Drosophila melanogaster", "taxonomic_id": 7227, - "reference_gene_identifier": 14 + "reference_gene_identifier": "FlyBase" }, { "id": 11, "name": "Canis familiaris", "taxonomic_id": 9615, - "reference_gene_identifier": 1 + "reference_gene_identifier": "Entrez" }, { "id": 2, "name": "Homo sapiens", "taxonomic_id": 9606, - "reference_gene_identifier": 11 + "reference_gene_identifier": "HGNC" }, { "id": 8, "name": "Caenorhabditis elegans", "taxonomic_id": 6239, - "reference_gene_identifier": 15 + "reference_gene_identifier": "Wormbase" }, { "id": 9, "name": "Saccharomyces cerevisiae", "taxonomic_id": 559292, - "reference_gene_identifier": 16 + "reference_gene_identifier": "SGD" }, { "id": 6, "name": "Macaca mulatta", "taxonomic_id": 9544, - "reference_gene_identifier": 1 + "reference_gene_identifier": "Entrez" } ] }, @@ -75,7 +75,7 @@ "id": 1, "name": "Mus musculus", "taxonomic_id": 10090, - "reference_gene_identifier": 10 + "reference_gene_identifier": "MGI" } ] }, @@ -85,7 +85,7 @@ "id": 5, "name": "Drosophila melanogaster", "taxonomic_id": 7227, - "reference_gene_identifier": 14 + "reference_gene_identifier": "FlyBase" } ] } diff --git a/tests/services/test_species.py b/tests/services/test_species.py index 6fdca6c..a65e6f9 100644 --- a/tests/services/test_species.py +++ b/tests/services/test_species.py @@ -6,12 +6,14 @@ from geneweaver.api.services import species as species_service from geneweaver.core.enum import GeneIdentifier -from tests.data import test_species_data +from tests.data import get_species_db_resp, test_species_data -species_no_params = test_species_data.get("species_no_params") -species_by_taxonomy_id_10090 = test_species_data.get("species_by_taxonomy_id_10090") -species_by_gene_id_type_flybase = test_species_data.get( - "species_by_gene_id_type_flybase" +species_no_params = get_species_db_resp(test_species_data.get("species_no_parameters")) +species_by_taxonomy_id_10090 = get_species_db_resp( + test_species_data.get("species_by_taxonomy_id_10090") +) +species_by_gene_id_type_flybase = get_species_db_resp( + test_species_data.get("species_by_gene_id_type_flybase") ) @@ -40,7 +42,9 @@ def test_get_species_by_gene_id_type(mock_db_species): """Test speccies by taxonomy id.""" mock_db_species.get.return_value = species_by_gene_id_type_flybase - response = species_service.get_species(None, gene_id_type=GeneIdentifier("FlyBase")) + response = species_service.get_species( + None, reference_gene_id_type=GeneIdentifier("FlyBase") + ) assert response.get("species") == species_by_gene_id_type_flybase @@ -51,7 +55,7 @@ def test_get_species_by_gene_id_type_and_taxonomy(mock_db_species): mock_db_species.get.return_value = species_by_gene_id_type_flybase response = species_service.get_species( - None, gene_id_type=GeneIdentifier("FlyBase"), taxonomy_id=7227 + None, reference_gene_id_type=GeneIdentifier("FlyBase"), taxonomy_id=7227 ) assert response.get("species") == species_by_gene_id_type_flybase @@ -64,19 +68,3 @@ def test_get_species_with_error(mock_db_species): with pytest.raises(expected_exception=Exception): species_service.get(None) - - -@patch("geneweaver.api.services.species.db_species") -def test_get_species_invalid_params(mock_db_species): - """Test speccies by taxonomy id.""" - mock_db_species.get.return_value = species_no_params - - # with pytest.raises(expected_exception=Exception): - - response = species_service.get_species( - None, taxonomy_id="qweqw", gene_id_type="asdasd" - ) - - # with pytest.raises(expected_exception=TypeError): - - assert response.get("species") == species_no_params From dbde2bea49c0f16f3129635dbde3317c949e10a6 Mon Sep 17 00:00:00 2001 From: francastell Date: Fri, 15 Mar 2024 15:22:42 -0400 Subject: [PATCH 3/3] doc update --- tests/data/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/__init__.py b/tests/data/__init__.py index 77d37ca..86c34ee 100644 --- a/tests/data/__init__.py +++ b/tests/data/__init__.py @@ -111,7 +111,7 @@ def get_species_db_resp(species_data: dict) -> dict: - """ " get species data as returned by DB.""" + """Get species data as returned by DB.""" species = species_data.get("species") for species_record in species: ref_gene_id_type = species_record.get("reference_gene_identifier", None)