def test_match_filtered_identities(self): """Test whether filtered identities match""" jsmith = EmailNameIdentity('1', None, '*****@*****.**', 'john smith') jsmith_alt = EmailNameIdentity('2', 'jsmith', None, 'john smith') jsmith_uuid = EmailNameIdentity('3', 'jsmith', '*****@*****.**', 'john') jsmith_none = EmailNameIdentity('4', 'jsmith', '*****@*****.**', None) jdoe_none = EmailNameIdentity('4', 'jdoe', '*****@*****.**', None) matcher = EmailNameMatcher() result = matcher.match_filtered_identities(jsmith, jsmith_alt) self.assertEqual(result, True) result = matcher.match_filtered_identities(jsmith, jsmith_uuid) self.assertEqual(result, False) result = matcher.match_filtered_identities(jsmith_alt, jsmith) self.assertEqual(result, True) result = matcher.match_filtered_identities(jsmith_alt, jsmith_uuid) self.assertEqual(result, True) result = matcher.match_filtered_identities(jsmith_uuid, jsmith) self.assertEqual(result, False) result = matcher.match_filtered_identities(jsmith_uuid, jsmith_alt) self.assertEqual(result, True) # Although the UUID is equal to None, these two does not match result = matcher.match_filtered_identities(jsmith_none, jdoe_none) self.assertEqual(result, False)
def test_match_filtered_identities_instances(self): """Test whether it raises an error when ids are not EmailNameIdentities""" fid = EmailNameIdentity('1', None, '*****@*****.**', 'john smith') matcher = EmailNameMatcher() self.assertRaises(ValueError, matcher.match_filtered_identities, 'John Smith', fid) self.assertRaises(ValueError, matcher.match_filtered_identities, fid, 'John Smith') self.assertRaises(ValueError, matcher.match_filtered_identities, None, fid) self.assertRaises(ValueError, matcher.match_filtered_identities, fid, None) self.assertRaises(ValueError, matcher.match_filtered_identities, 'John Smith', 'John Doe')