aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_search.py
diff options
context:
space:
mode:
authorArun Isaac2023-01-24 18:17:57 +0000
committerArun Isaac2023-01-24 18:30:05 +0000
commite5bcdbc83031c10092f1405b847695ecefbada44 (patch)
tree6660629c849b38c3bc2344dfd7127b3acca8af26 /tests/unit/test_search.py
parentd33454f3e7fb7810fd4b7a987e6a68b3c48ec98e (diff)
downloadgenenetwork3-e5bcdbc83031c10092f1405b847695ecefbada44.tar.gz
search: Abstract out parsing of position spec into separate function.
* gn3/api/search.py (parse_position): New function. (parse_location_field): Use parse_position. * tests/unit/test_search.py: Import parse_position from gn3.api.search. (test_parse_position_close_to_zero_location): New test.
Diffstat (limited to 'tests/unit/test_search.py')
-rw-r--r--tests/unit/test_search.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index ec89a61..c535c60 100644
--- a/tests/unit/test_search.py
+++ b/tests/unit/test_search.py
@@ -3,7 +3,7 @@ from hypothesis import given, strategies as st
from pymonad.maybe import Just, Nothing
import pytest
-from gn3.api.search import apply_si_suffix, parse_range
+from gn3.api.search import apply_si_suffix, parse_range, parse_position
@pytest.mark.unit_test
@given(st.decimals(places=3, allow_nan=False, allow_infinity=False),
@@ -74,3 +74,12 @@ def test_parse_range_right_open_interval():
and no value (Nothing) for the ending of the range
"""
assert parse_range("foo..") == (Just("foo"), Nothing)
+
+@pytest.mark.unit_test
+def test_parse_position_close_to_zero_location():
+ """
+ GIVEN: A point location close to zero
+ WHEN: we parse the range
+ THEN: set the lower limit to zero, not a negative number
+ """
+ assert parse_position("25K")[0] == Just(0)