diff options
author | Frederick Muriuki Muriithi | 2022-02-19 03:21:27 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-02-19 03:21:27 +0300 |
commit | 058f6592d8815a64544f6721a9984b89ea92522a (patch) | |
tree | 2d2788432457ffda4570debed723b727057e3a7d /gn3/db | |
parent | de56919183e7b86cd3e495c6274174720dd9ae3a (diff) | |
download | genenetwork3-058f6592d8815a64544f6721a9984b89ea92522a.tar.gz |
Test partial corrs endpoint with non-existing control traits
Test that if the endpoint is queried and not a single one of the control
traits exists in the database, then the endpoint will respond with a
404 (not-found) status code.
Summary of changes:
* gn3/computations/partial_correlations.py: Check whether any control trait is
found. If none is found, return "not-found" message.
* gn3/db/partial_correlations.py: Fix bug in Geno query.
* tests/integration/test_partial_correlations.py: Add test for non-existing
control traits. Rename function to make it clearer what it is testing
for. Remove obsoleted comments.
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/partial_correlations.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gn3/db/partial_correlations.py b/gn3/db/partial_correlations.py index caf8d35..0931f09 100644 --- a/gn3/db/partial_correlations.py +++ b/gn3/db/partial_correlations.py @@ -197,13 +197,14 @@ def geno_traits_data(conn, traits): "AND GenoXRef.DataId = GenoData.Id " "AND GenoData.StrainId = Strain.Id " "ORDER BY Strain.Name").format( - species_ids=sp_ids, + species_ids=", ".join(["%s"] * len(sp_ids)), trait_names=", ".join(["%s"] * len(traits)), dataset_names=", ".join(["%s"] * len(dataset_names))) if len(sp_ids) > 0 and len(dataset_names) > 0: with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( query, + sp_ids + tuple(trait["trait_name"] for trait in traits) + tuple(dataset_names)) return organise_trait_data_by_trait(cursor.fetchall()) |