From ef9f5a4d70e2f78f1fcd39bc8b916583d5329529 Mon Sep 17 00:00:00 2001 From: asherpasha Date: Thu, 2 Nov 2023 17:35:06 -0400 Subject: [PATCH] Updated eFP data source service. --- api/resources/efp_image.py | 8 ++++++-- requirements.txt | 6 +++--- tests/resources/test_efp_image.py | 8 ++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/api/resources/efp_image.py b/api/resources/efp_image.py index bc2218b..2f6bb55 100644 --- a/api/resources/efp_image.py +++ b/api/resources/efp_image.py @@ -145,13 +145,14 @@ def get(self, species=""): Supported species: Sorghum """ + species = escape(species) species = species.lower() results = [] # This will only work on the BAR if os.environ.get("BAR"): - if species == "sorghum": - efp_base_path = "/var/www/html/efp_sorghum/data" + if species in ["arabidopsis", "arachis", "cannabis", "maize", "sorghum", "soybean"]: + efp_base_path = "/var/www/html/efp_" + species + "/data" else: return BARUtils.error_exit("Invalid species.") @@ -175,6 +176,7 @@ def get(self, species=""): Supported species: Arabidopsis, Poplar """ + species = escape(species) species = species.lower() if species == "arabidopsis": @@ -189,6 +191,8 @@ def get(self, species=""): XML_name = "Populus_trichocarpa.xml" SVG_name = "Populus_trichocarpa.svg" base_url = "//bar.utoronto.ca/eplant_poplar/data/" + else: + return BARUtils.error_exit("Invalid species.") efp_folders = os.listdir(efp_base_path) diff --git a/requirements.txt b/requirements.txt index 5f9ad98..9a95cca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,10 @@ aniso8601==9.0.1 async-timeout==4.0.3 attrs==23.1.0 black==23.10.1 -blinker==1.6.3 +blinker==1.7.0 cachelib==0.9.0 certifi==2023.7.22 -charset-normalizer==3.3.1 +charset-normalizer==3.3.2 click==8.1.7 coverage==7.3.2 Deprecated==1.2.14 @@ -51,7 +51,7 @@ requests==2.31.0 rich==13.6.0 rpds-py==0.10.6 six==1.16.0 -SQLAlchemy==2.0.22 +SQLAlchemy==2.0.23 typing_extensions==4.8.0 urllib3==2.0.7 Werkzeug==2.3.7 diff --git a/tests/resources/test_efp_image.py b/tests/resources/test_efp_image.py index 4087d63..6cc8f3b 100644 --- a/tests/resources/test_efp_image.py +++ b/tests/resources/test_efp_image.py @@ -24,6 +24,14 @@ def test_get_efp_image_list(self): } self.assertEqual(response.json, expected) + def test_get_efp_data_source(self): + """This function tests eFP data source error return + :return: + """ + response = self.app_client.get("/efp_image/get_efp_data_source/soybean") + expected = {"wasSuccessful": False, "error": "Only available on the BAR."} + self.assertEqual(response.json, expected) + def test_get_efp_image(self): """This function test eFP image endpoint get request :return: