def test_check_file_permission_is_true(self): self.path = join(HERE, 'test_data', 'Executable file') self.string = "ERROR: .{path}/file_permission.py is marked as stand-alone executable".format( path=self.path) file_index = create_file_index(self.path) check_file_permission(self.report, file_index) records = [ Record.__str__(r) for r in ReportManager.getEnabledReporters()[0].reports ] flag = any(s == self.string for s in records) self.assertTrue(flag)
def test_gitignore(self): path = join(HERE, 'test_data', 'GitIgnore') string = "WARN: Found non whitelisted file ending in filename {path}" \ .format(path=relative_path(join(path, ".gitignore"))) file_index = create_file_index(path) check_file_whitelist(self.report, file_index, path) records = [ Record.__str__(r) for r in ReportManager.getEnabledReporters()[0].reports ] self.assertGreater(len(records), 0) self.assertEqual(records[-1], string)
def test_check_file_permission_is_true(self): path = join(HERE, 'test_data', 'Executable_file') string = "ERROR: {path} is marked as stand-alone executable"\ .format(path=relative_path(join(path, "file_permission.py"))) file_index = create_file_index(path) check_file_permission(self.report, file_index) records = [ Record.__str__(r) for r in ReportManager.getEnabledReporters()[0].reports ] flag = any(s == string for s in records) if os.name == "nt": self.assertFalse(flag) else: self.assertTrue(flag)
def test_create_file_index(self): self.path = join(HERE, 'test_data', 'File_index/') self.list = [{'path': self.path, 'name': 'file_index.py'}] self.output = create_file_index(self.path) self.assertListEqual(self.output, self.list)
def test_create_file_index(self): path = join(HERE, 'test_data', 'File_index/') expected_list = [{'path': path, 'name': 'file_index.py'}] output = create_file_index(path) self.assertListEqual(output, expected_list)
def test_check_file_permission_is_None(self): self.path = join(HERE, 'test_data', 'Non-Executable file') file_index = create_file_index(self.path) self.assertIsNone(check_file_permission(self.report, file_index))