576ea95b6d
DAIP2-112 - fixed get code descriptions * indirect proc codes added * bug fix * bug fix * Merge branch 'main' into proc-code-indirect * description mapping handling X's and 0's * bug fix * Merge remote-tracking branch 'origin/proc-code-indirect' into code-breakout-mismaps * testing mismaps * revenue codes mapping for int values * added function to find ranges * removed test files * Merged main into code-breakout-mismaps * Merge branch 'main' into code-breakout-mismaps pulled latest changes from main * added unit test for find containing ranges * modified find_containing_ranges_test file * Merged main into code-breakout-mismaps * added embeddings to git ignore * updated find_containing_ranges_test.py Approved-by: Alex Galarce Approved-by: Katon Minhas
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
import pytest
|
|
from unittest.mock import patch, MagicMock
|
|
from src.investment.code_funcs import find_containing_ranges
|
|
|
|
def test_find_containing_ranges_valid_input():
|
|
input_range = '70010-79999'
|
|
code_mapping = {
|
|
'70000-70050': 'Description 1',
|
|
'70040-70060': 'Description 2',
|
|
'70010-70020': 'Description 3',
|
|
'80000-80050': 'Description 4'
|
|
}
|
|
expected_output = ['70000-70050', '70040-70060']
|
|
assert find_containing_ranges(input_range, code_mapping) == expected_output
|
|
|
|
def test_find_containing_ranges_no_overlap():
|
|
input_range = '70010-70020'
|
|
code_mapping = {
|
|
'70030-70040': 'Description 1',
|
|
'70050-70060': 'Description 2',
|
|
'80000-80050': 'Description 3'
|
|
}
|
|
expected_output = []
|
|
assert find_containing_ranges(input_range, code_mapping) == expected_output
|
|
|
|
def test_find_containing_ranges_partial_overlap():
|
|
input_range = '70010-70050'
|
|
code_mapping = {
|
|
'70000-70020': 'Description 1',
|
|
'70040-70060': 'Description 2',
|
|
'70050-70070': 'Description 3'
|
|
}
|
|
expected_output = ['70000-70020', '70040-70060']
|
|
assert find_containing_ranges(input_range, code_mapping) == expected_output
|
|
|
|
def test_find_containing_ranges_exact_match():
|
|
input_range = '70000-70050'
|
|
code_mapping = {
|
|
'70000-70050': 'Description 1',
|
|
'70040-70060': 'Description 2',
|
|
'70010-70020': 'Description 3'
|
|
}
|
|
expected_output = ['70000-70050']
|
|
assert find_containing_ranges(input_range, code_mapping) == expected_output
|
|
|
|
def test_find_containing_ranges_empty_mapping():
|
|
input_range = '70000-70050'
|
|
code_mapping = {}
|
|
expected_output = []
|
|
assert find_containing_ranges(input_range, code_mapping) == expected_output
|
|
|
|
def test_find_containing_ranges_invalid_input():
|
|
input_range = 'invalid-range'
|
|
code_mapping = {
|
|
'70000-70050': 'Description 1',
|
|
'70040-70060': 'Description 2'
|
|
}
|
|
with pytest.raises(ValueError):
|
|
find_containing_ranges(input_range, code_mapping) |