def test_Single(self): target = Target({}) actual = target.unique_matches( [ { 'found_item': [ { 'display_name': 'high heels', 'key': 'high heels', 'match_type': 'alias', 'source': 'content', 'type': 'style' } ], 'start': 10, 'end': 16, 'term': 'high heels', 'tokens': ['high heels'] } ] ) self.assertListEqual( actual, [ { 'source': 'content', 'type': 'style', 'key': 'high heels' } ] )
def test_mix_spelling_alias(self): target = Target({}) actual = target.unique_matches([{ 'found_item': [{ 'display_name': 'citrus', 'key': 'citrus', 'match_type': 'alias', 'source': 'content', 'type': 'color' }], 'start': 0, 'end': 6, 'term': 'citrus', 'tokens': ['citrus'] }, { 'found_item': [{ 'display_name': 'citrus', 'key': 'citrus', 'match_type': 'spelling', 'source': 'content', 'type': 'color' }], 'start': 10, 'end': 16, 'term': 'citrus', 'tokens': ['citrus'] }, { 'found_item': [{ 'display_name': 'high heels', 'key': 'high heels', 'match_type': 'alias', 'source': 'content', 'type': 'style' }], 'start': 10, 'end': 16, 'term': 'high heels', 'tokens': ['high heels'] }]) self.assertEqual(len(actual), 2) self.assertTrue({ 'source': 'content', 'type': 'color', 'key': 'citrus' } in actual) self.assertTrue({ 'source': 'content', 'type': 'style', 'key': 'high heels' } in actual)
def test_no_duplicates(self): target = Target({}) actual = target.unique_matches( [ { 'found_item': [ { 'display_name': 'citrus', 'key': 'citrus', 'match_type': 'alias', 'source': 'content', 'type': 'color' } ], 'start': 0, 'end': 6, 'term': 'citrus', 'tokens': ['citrus'] }, { 'found_item': [ { 'display_name': 'high heels', 'key': 'high heels', 'match_type': 'alias', 'source': 'content', 'type': 'style' } ], 'start': 10, 'end': 16, 'term': 'high heels', 'tokens': ['high heels'] } ] ) self.assertEqual( len(actual), 2 ) self.assertTrue( { 'source': 'content', 'type': 'color', 'key': 'citrus' } in actual ) self.assertTrue( { 'source': 'content', 'type': 'style', 'key': 'high heels' } in actual )
def test_Single(self): target = Target({}) actual = target.unique_matches([{ 'found_item': [{ 'display_name': 'high heels', 'key': 'high heels', 'match_type': 'alias', 'source': 'content', 'type': 'style' }], 'start': 10, 'end': 16, 'term': 'high heels', 'tokens': ['high heels'] }]) self.assertListEqual(actual, [{ 'source': 'content', 'type': 'style', 'key': 'high heels' }])