def test_fetch_pylint(self): """Test whether commits are properly processed""" cq = CoQua('http://example.com', self.git_path, self.worktree_path, entrypoint="perceval") commits = [commit for commit in cq.fetch()] self.assertEqual(len(commits), 6) self.assertFalse(os.path.exists(cq.worktreepath)) commit = commits[0] self.assertEqual(commit['backend_name'], 'CoQua') self.assertEqual(commit['category'], CATEGORY_COQUA_PYLINT) result = commit['data']['analysis'] self.assertNotIn('modules', result) self.assertIn('quality', result) self.assertTrue(type(result['quality']), str) self.assertIn('num_modules', result) self.assertTrue(type(result['num_modules']), int) self.assertIn('warnings', result) self.assertTrue(type(result['warnings']), int)
def test_fetch_error(self): """Test whether an exception is thrown when the exec_path isn't defined and the category is jadolint""" cq = CoQua('http://example.com', self.git_path, self.worktree_path, entrypoint="module", tag='test') with self.assertRaises(GraalError): _ = [item for item in cq.fetch(category=CATEGORY_COQUA_JADOLINT)]
def test_fetch(self): """Test whether commits are properly processed""" cq = CoQua('http://example.com', self.git_path, self.worktree_path, exec_path=JADOLINT_PATH, in_paths=['Dockerfile']) commits = [commit for commit in cq.fetch(category=CATEGORY_COQUA_JADOLINT)] self.assertEqual(len(commits), 2) analysis = commits[0]['data']['analysis'] self.assertIn('Dockerfile', analysis) expected_smells = [ '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 13 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 16 DL3008 Pin versions in apt-get install', '/Dockerfile 16 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 16 DL3014 Use the -y switch', '/Dockerfile 16 DL3015 Avoid additional packages by specifying --no-install-recommends', '/Dockerfile 32 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 34 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 34 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 37 DL3020 Use COPY instead of ADD for files and folders', '/Dockerfile 38 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 40 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 55 DL3000 Use absolute WORKDIR', '/Dockerfile 57 DL3025 Use arguments JSON notation for CMD and ENTRYPOINT arguments' ] analysis['Dockerfile'][SMELLS].sort() expected_smells.sort() self.assertListEqual(analysis['Dockerfile'][SMELLS], expected_smells) analysis = commits[1]['data']['analysis'] self.assertIn('Dockerfile', analysis) expected_smells = [ '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 5 DL4000 MAINTAINER is deprecated', '/Dockerfile 13 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 16 DL3008 Pin versions in apt-get install', '/Dockerfile 16 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 16 DL3014 Use the -y switch', '/Dockerfile 16 DL3015 Avoid additional packages by specifying --no-install-recommends', '/Dockerfile 33 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 35 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 35 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 38 DL3020 Use COPY instead of ADD for files and folders', '/Dockerfile 39 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 41 DL3009 Delete the apt-get lists after installing something', '/Dockerfile 56 DL3000 Use absolute WORKDIR', '/Dockerfile 58 DL3025 Use arguments JSON notation for CMD and ENTRYPOINT arguments' ] analysis['Dockerfile'][SMELLS].sort() expected_smells.sort() self.assertListEqual(analysis['Dockerfile'][SMELLS], expected_smells)