From e5bcdbc83031c10092f1405b847695ecefbada44 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 24 Jan 2023 18:17:57 +0000 Subject: 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. --- tests/unit/test_search.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') 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) -- cgit v1.2.3