def test_finish_filter_row_ordering(): # Test non-exclusive ordering of RoW; RoW not key given = { 'A': set(range(10)), 'B': {2, 3, 4}, 'C': {3, 4, 5}, 'D': {10, 11}, 'E': {5, 6, 10}, } g = Geomatcher(given) lst = [('B', 6), ('RoW', 7), ('D', 8), ('E', 9)] result = g._finish_filter(lst, 'A', False, False, True) assert result[-1] == 'RoW' result = g._finish_filter(lst, 'A', False, False, False) assert result[0] == 'RoW'
def test_finish_filter_exclusive(): given = { 'A': {1, 2, 3}, 'B': {2, 3, 4}, 'C': {3, 4, 5}, 'D': {10, 11}, 'E': {5, 6, 10}, } g = Geomatcher(given) lst = [('A', 5), ('B', 6), ('C', 7), ('D', 8), ('E', 9)] result = g._finish_filter(lst, 'A', True, True, True) # Start with E (biggest), then B (next possible) assert result == ["E", "B"] result = g._finish_filter(lst, 'A', True, True, False) # Start with A (smallest), then D (next possible) assert result == ['A', 'D']
def test_finish_filter_row_exclusive_row_key(): g = Geomatcher() assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1)], 'RoW', False, True, True) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1)], 'RoW', True, True, True) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1), ('RoW', 0)], 'RoW', False, True, True) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1), ('RoW', 0)], 'RoW', True, True, True) == ['RoW'] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1)], 'RoW', False, True, False) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1)], 'RoW', True, True, False) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1), ('RoW', 0)], 'RoW', False, True, False) == [] assert g._finish_filter([('NO', 4), ('LT', 3), ('LV', 2), ('EE', 1), ('RoW', 0)], 'RoW', True, True, False) == ['RoW']
def test_finish_filter_not_include_self(): g = Geomatcher({'A': {1, 2}}) given = [('A', 4), ('B', 6), ('C', 3)] assert g._finish_filter(deepcopy(given), 'A', False, False, True) == ['B', 'C'] assert g._finish_filter(deepcopy(given), 'A', False, False, False) == ['C', 'B']