def test_union(self): cases = [ ( 'both sets are empty', sut.SeeAlsoSet([]), sut.SeeAlsoSet([]), 0, ), ( 'one empty and one non-empty', sut.SeeAlsoSet([CustomCrossReferenceId('an_element')]), sut.SeeAlsoSet([]), 1, ), ( 'two non-empty with different elements', sut.SeeAlsoSet([CustomCrossReferenceId('a')]), sut.SeeAlsoSet([CustomCrossReferenceId('b')]), 2, ), ( 'two non-empty with equal elements', sut.SeeAlsoSet([CustomCrossReferenceId('a')]), sut.SeeAlsoSet([CustomCrossReferenceId('a')]), 1, ), ] for name, a, b, expected_size in cases: with self.subTest(name=name): actual = a.union(b) self.assertEqual(expected_size, len(actual.see_also_items))
def test_elements_SHOULD_be_translated_to_see_also_items(self): cases = [ NameAndValue('empty', (sut.SeeAlsoSet([]), asrt.matches_sequence([]))), NameAndValue('single cross ref', (sut.SeeAlsoSet([CustomCrossReferenceId('target')]), asrt.matches_sequence([is_see_also_item]))), NameAndValue('single see also url info', (sut.SeeAlsoSet([sut.SeeAlsoUrlInfo('name', 'url')]), asrt.matches_sequence([is_see_also_item]))), NameAndValue(' see also url info and cross ref', (sut.SeeAlsoSet([ sut.SeeAlsoUrlInfo('name', 'url'), TestCasePhaseInstructionCrossReference('phase', 'instruction') ]), asrt.matches_sequence([is_see_also_item, is_see_also_item]))), ] for case in cases: see_also_set, assertion = case.value with self.subTest(name=case.name): # ACT # actual = see_also_set.see_also_items # ASSERT # assertion.apply_without_message(self, actual)
def test_create_non_empty_with_duplicate_elements(self): element = CustomCrossReferenceId('an_element') actual = sut.SeeAlsoSet([element, element]) self.assertEqual(1, len(actual.see_also_items))
def test_create_empty(self): actual = sut.SeeAlsoSet([]) self.assertEqual(0, len(actual.see_also_items))