def test__multiple_merges(self): data = [ { 'string': 'abc', 'selection': ( (0, 1), (1, 2), (3, 4), (6, 7), (7, 8) ) } ] expected = [ { 'string': 'abc', 'selection': ( (0, 2), (3, 4), (6, 8) ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__multiple_nodes_can_processed_yes_yes(self): data = [ { 'string': 'yes', 'selection': ( (0, 1), (1, 2) ) }, { 'string': 'yes', 'selection': ( (0, 1), (1, 2) ) } ] expected = [ { 'string': 'yes', 'selection': ( (0, 2), ) }, { 'string': 'yes', 'selection': ( (0, 2), ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__chaining_merges(self): data = [{ 'string': 'abc', 'selection': ((0, 1), (1, 2), (2, 3), (3, 4), (4, 5)) }] expected = [{'string': 'abc', 'selection': ((0, 5), )}] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__multiple_merges(self): data = [{ 'string': 'abc', 'selection': ((0, 1), (1, 2), (3, 4), (6, 7), (7, 8)) }] expected = [{'string': 'abc', 'selection': ((0, 2), (3, 4), (6, 8))}] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__item_after_the_merge(self): data = [{'string': 'abc', 'selection': ((0, 1), (1, 2), (3, 4))}] expected = [{ 'string': 'abc', 'selection': ( (0, 2), (3, 4), ) }] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__no_selection_no_merge_needed(self): data = [ { 'string': 'abc', 'selection': () } ] expected = [ { 'string': 'abc', 'selection': () } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__multiple_nodes_can_processed_no_no(self): data = [{ 'string': 'no', 'selection': () }, { 'string': 'no', 'selection': () }] expected = [{ 'string': 'no', 'selection': () }, { 'string': 'no', 'selection': () }] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__multiple_nodes_can_processed_yes_yes(self): data = [{ 'string': 'yes', 'selection': ((0, 1), (1, 2)) }, { 'string': 'yes', 'selection': ((0, 1), (1, 2)) }] expected = [{ 'string': 'yes', 'selection': ((0, 2), ) }, { 'string': 'yes', 'selection': ((0, 2), ) }] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__structure_with_selections_next_to_each_other_will_merged(self): data = [ { 'string': 'abc', 'selection': ( (0, 1), (1, 2) ) } ] expected = [ { 'string': 'abc', 'selection': ( (0, 2), ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__two_no_mergable_selections(self): data = [ { 'string': 'abc', 'selection': ( (1, 2), (5, 6) ) } ] expected = [ { 'string': 'abc', 'selection': ( (1, 2), (5, 6) ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__item_after_the_merge(self): data = [ { 'string': 'abc', 'selection': ( (0, 1), (1, 2), (3, 4) ) } ] expected = [ { 'string': 'abc', 'selection': ( (0, 2), (3, 4), ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__chaining_merges(self): data = [ { 'string': 'abc', 'selection': ( (0, 1), (1, 2), (2, 3), (3, 4), (4, 5) ) } ] expected = [ { 'string': 'abc', 'selection': ( (0, 5), ) } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__multiple_nodes_can_processed_no_no(self): data = [ { 'string': 'no', 'selection': () }, { 'string': 'no', 'selection': () } ] expected = [ { 'string': 'no', 'selection': () }, { 'string': 'no', 'selection': () } ] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__structure_with_selections_next_to_each_other_will_merged(self): data = [{'string': 'abc', 'selection': ((0, 1), (1, 2))}] expected = [{'string': 'abc', 'selection': ((0, 2), )}] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__two_no_mergable_selections(self): data = [{'string': 'abc', 'selection': ((1, 2), (5, 6))}] expected = [{'string': 'abc', 'selection': ((1, 2), (5, 6))}] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)
def test__single_selection_no_merge_needed(self): data = [{'string': 'abc', 'selection': ((1, 2), )}] expected = [{'string': 'abc', 'selection': ((1, 2), )}] project_selector._merge_neighbour_selections(data) self.assertEqual(expected, data)