Ejemplo n.º 1
0
    def test_AddBlacklistPatterns_PatternIsNone_BlacklistIsUnchanged(self):
        file_approver = FileApprover()
        file_approver.blacklist = self.get_sample_set()

        file_approver.add_blacklist_patterns(None)

        self.assertEqual(self.get_sample_set(), file_approver.blacklist)
Ejemplo n.º 2
0
    def test_AddBlacklist_GetPatternsFromFileReturnsNone_BlacklistIsUnchanged(self, mock_get_patterns):
        file_approver = FileApprover()
        file_approver.blacklist = self.get_sample_set()
        mock_get_patterns.return_value = None

        file_approver.add_blacklist("path/to/blacklist")

        self.assertEqual(self.get_sample_set(), file_approver.blacklist)
Ejemplo n.º 3
0
    def test_AddBlacklistPatterns_ValidListOfPatternsBlacklistHasValues_BlacklistHasNewPatterns(self):
        file_approver = FileApprover()
        file_approver.blacklist = self.get_sample_set()
        test_patterns = ["pattern1", "pattern4", "pattern5"]

        file_approver.add_blacklist_patterns(test_patterns)

        expected_patterns = self.get_sample_set() | set(test_patterns)
        self.assertSetEqual(expected_patterns, file_approver.blacklist)
Ejemplo n.º 4
0
    def test_AddBlacklistPatterns_ValidPatternBlacklistHasValues_BlacklastHasNewPattern(self):
        file_approver = FileApprover()
        file_approver.blacklist = self.get_sample_set()
        test_pattern = "pattern4"

        file_approver.add_blacklist_patterns(test_pattern)

        expected_patterns = self.get_sample_set() | {test_pattern}
        self.assertEqual(expected_patterns, file_approver.blacklist)
Ejemplo n.º 5
0
    def test_IsBlacklisted_FilenameGiven_IsInListCalledWithFilenameAndReturns(self, mock_in_list):
        file_approver = FileApprover()
        test_blacklist = ['testPattern']
        file_approver.blacklist = test_blacklist
        test_filename = "testModule.dll"
        mock_in_list.return_value = True

        blacklisted = file_approver.is_blacklisted(test_filename)

        mock_in_list.assert_called_with(test_filename, test_blacklist)
        self.assertTrue(blacklisted)
Ejemplo n.º 6
0
    def test_AddBlacklist_ValidBlacklistFileAndBlacklistHasValues_BlacklistHasNewPatterns(self, mock_get_patterns):
        file_approver = FileApprover()
        file_approver.blacklist = self.get_sample_set()
        test_patterns = {'pattern1', 'pattern4'}
        test_filename = "path/to/blacklist"
        mock_get_patterns.return_value = test_patterns

        file_approver.add_blacklist(test_filename)

        mock_get_patterns.assert_called_with(test_filename)
        expected_patterns = test_patterns | self.get_sample_set()
        self.assertEqual(expected_patterns, file_approver.blacklist)