Skip to content

Commit

Permalink
Merge pull request #200 from asherpasha/dev
Browse files Browse the repository at this point in the history
Updated eFP data source service.
  • Loading branch information
asherpasha authored Nov 2, 2023
2 parents 146e4d0 + ef9f5a4 commit 811621b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions api/resources/efp_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand All @@ -175,6 +176,7 @@ def get(self, species=""):
Supported species: Arabidopsis, Poplar
"""

species = escape(species)
species = species.lower()

if species == "arabidopsis":
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/resources/test_efp_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 811621b

Please sign in to comment.