diff options
author | Frederick Muriuki Muriithi | 2022-02-18 07:17:50 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-02-18 07:17:50 +0300 |
commit | 83a7aa7533f8f4ecac049dc0e93aff6429e6e5ae (patch) | |
tree | 0d0e77acba6570a7362c1380fa606535bc90e216 /gn3/computations | |
parent | 12db8134081bc679565dfff1aaa2da81f913dd9d (diff) | |
download | genenetwork3-83a7aa7533f8f4ecac049dc0e93aff6429e6e5ae.tar.gz |
Test partial correlations endpoint with non-existent primary traits
Test that the partial correlations endpoint responds with an appropriate "not-found" message and the corresponding 404 status code in the case where a request is made and the primary trait requested for does not exist in the database. Summary of the changes in each file: * gn3/api/correlation.py: generalise the building of the response * gn3/computations/partial_correlations.py: return with a "not-found" if the primary trait does not exist in the database * gn3/db/partial_correlations.py: Fix a number of bugs that led to exceptions in the case that the primary trait did not exist * pytest.ini: register a `slow` pytest marker * tests/integration/test_partial_correlations.py: Add a new test to check for an appropriate 404 response in case of a primary trait that does not exist in the database.
Diffstat (limited to 'gn3/computations')
-rw-r--r-- | gn3/computations/partial_correlations.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index 85e3c11..16cbbdb 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -616,6 +616,11 @@ def partial_correlations_entry(# pylint: disable=[R0913, R0914, R0911] primary_trait = tuple( trait for trait in all_traits if trait["trait_fullname"] == primary_trait_name)[0] + if not primary_trait["haveinfo"]: + return { + "status": "not-found", + "message": f"Could not find primary trait {primary_trait['trait_fullname']}" + } group = primary_trait["db"]["group"] primary_trait_data = all_traits_data[primary_trait["trait_name"]] primary_samples, primary_values, _primary_variances = export_informative( |