diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index c36c7b68e..31f627b6c 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -41,19 +41,20 @@ def find_amount_ranges(amount, operation): :return: A list of matching keys. """ amount = int(amount) - import ipdb - - ipdb.set_trace() if operation == "lt": + if amount < tender_constants.AMOUNT_RANGE_CHOICE_EXACT.get(tender_constants.AMOUNT_RANGE_0_1): + return [tender_constants.AMOUNT_RANGE_0_1] return [key for key, value in tender_constants.AMOUNT_RANGE_CHOICE_EXACT.items() if value < amount] elif operation == "lte": + if amount <= tender_constants.AMOUNT_RANGE_CHOICE_EXACT.get(tender_constants.AMOUNT_RANGE_0_1): + return [tender_constants.AMOUNT_RANGE_0_1] return [key for key, value in tender_constants.AMOUNT_RANGE_CHOICE_EXACT.items() if value <= amount] elif operation == "gt": - if amount >= 10 * 10**5: + if amount >= tender_constants.AMOUNT_RANGE_CHOICE_EXACT.get(tender_constants.AMOUNT_RANGE_1000_MORE): return [tender_constants.AMOUNT_RANGE_1000_MORE] return [key for key, value in tender_constants.AMOUNT_RANGE_CHOICE_EXACT.items() if value > amount] elif operation == "gte": - if amount >= 10 * 10**5: + if amount >= tender_constants.AMOUNT_RANGE_CHOICE_EXACT.get(tender_constants.AMOUNT_RANGE_1000_MORE): return [tender_constants.AMOUNT_RANGE_1000_MORE] return [key for key, value in tender_constants.AMOUNT_RANGE_CHOICE_EXACT.items() if value >= amount] else: diff --git a/lemarche/tenders/tests.py b/lemarche/tenders/tests.py index 2224f1a41..394866102 100644 --- a/lemarche/tenders/tests.py +++ b/lemarche/tenders/tests.py @@ -982,7 +982,6 @@ def test_gte_operation(self): tender_constants.AMOUNT_RANGE_750_1000, tender_constants.AMOUNT_RANGE_1000_MORE, ] - print("find_amount_ranges(250000", find_amount_ranges(250000, "gte")) self.assertListEqual(find_amount_ranges(250000, "gte"), expected_keys) def test_lt_operation(self): @@ -1006,4 +1005,4 @@ def test_edge_case(self): def test_no_matching_ranges(self): """Test when no ranges match the criteria.""" - self.assertListEqual(find_amount_ranges(100, "gte"), [tender_constants.AMOUNT_RANGE_0_1]) + self.assertListEqual(find_amount_ranges(100, "lte"), [tender_constants.AMOUNT_RANGE_0_1])