Skip to content

Commit b59acb2

Browse files
authored
Merge pull request #304 from VinLau/dev
fixed regex for get_trees and timeseries endpoints in FastPheno to accept individual trees via . like 619.03
2 parents bf992e1 + d21eb38 commit b59acb2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

api/resources/fastpheno.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get(self, tree_site_id):
8383
tree_site_id = str(escape(tree_site_id))
8484
site = request.args.get("site")
8585

86-
if not re.search(r"^[a-zA-Z0-9]{1,10}$", tree_site_id):
86+
if not re.search(r"^[a-zA-Z0-9.]{1,15}$", tree_site_id):
8787
return BARUtils.error_exit("Invalid tree site ID"), 400
8888

8989
if site is not None:
@@ -179,7 +179,7 @@ def get(self, tree_site_id, band):
179179
band = str(escape(band))
180180
site = request.args.get("site")
181181

182-
if not re.search(r"^[a-zA-Z0-9]{1,10}$", tree_site_id):
182+
if not re.search(r"^[a-zA-Z0-9.]{1,15}$", tree_site_id):
183183
return BARUtils.error_exit("Invalid tree site ID"), 400
184184

185185
if not re.search(r"^[a-zA-Z0-9_]{1,20}$", band):

tests/resources/test_fastpheno.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def test_get_trees(self):
152152
expected = {"wasSuccessful": False, "error": "No data found for the given parameters"}
153153
self.assertEqual(response.json, expected)
154154

155-
# Invalid tree_site_id (too long)
156-
response = self.app_client.get("/fastpheno/get_trees/TOOLONGID12345")
155+
# Invalid tree_site_id (contains disallowed character)
156+
response = self.app_client.get("/fastpheno/get_trees/619!")
157157
expected = {"wasSuccessful": False, "error": "Invalid tree site ID"}
158158
self.assertEqual(response.json, expected)
159159

@@ -231,8 +231,8 @@ def test_timeseries_genotype_aggregate(self):
231231
expected = {"wasSuccessful": False, "error": "No data found for the given parameters"}
232232
self.assertEqual(response.json, expected)
233233

234-
# Invalid tree_site_id (too long)
235-
response = self.app_client.get("/fastpheno/timeseries/genotype/TOOLONGID123/398nm/aggregate")
234+
# Invalid tree_site_id (contains disallowed character)
235+
response = self.app_client.get("/fastpheno/timeseries/genotype/619!/398nm/aggregate")
236236
expected = {"wasSuccessful": False, "error": "Invalid tree site ID"}
237237
self.assertEqual(response.json, expected)
238238

0 commit comments

Comments
 (0)