コード例 #1
0
    def test_match_filtered_identities_with_blacklist(self):
        """Test whether filtered identities match when there is a blacklist"""

        jsmith = GitHubUsernameIdentity('1', None, 'jsmith', 'github-commits')
        jsmith_alt = GitHubUsernameIdentity('2', 'jsmith', 'jsmith', 'github')
        jsmith_uuid = GitHubUsernameIdentity('3', 'jsmith', 'jsmith',
                                             'GitHub-API')
        john_none = GitHubUsernameIdentity('4', None, 'jsmith',
                                           'github-issues')

        bl = [MatchingBlacklist(excluded='jsmith')]

        matcher = GitHubMatcher(blacklist=bl)

        result = matcher.match_filtered_identities(jsmith, jsmith_alt)
        self.assertEqual(result, False)

        result = matcher.match_filtered_identities(jsmith, jsmith_uuid)
        self.assertEqual(result, False)

        result = matcher.match_filtered_identities(jsmith_alt, jsmith)
        self.assertEqual(result, False)

        # Same UUID
        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)

        # Although the UUID is equal to None, these two does not match
        result = matcher.match_filtered_identities(jsmith, john_none)
        self.assertEqual(result, False)
コード例 #2
0
    def test_match_filtered_identities(self):
        """Test whether filtered identities match"""

        jsmith = GitHubUsernameIdentity('1', None, 'jsmith', 'github')
        jsmith_alt = GitHubUsernameIdentity('2', 'jsmith', 'jsmith',
                                            'GitHub-API')
        jsmith_uuid = GitHubUsernameIdentity('3', 'jsmith', 'john.smith',
                                             'github')

        matcher = GitHubMatcher()

        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)