Пример #1
0
    def test_fetch(self):
        """Test whether commits are properly processed"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   entrypoint="perceval")
        commits = [commit for commit in cd.fetch()]

        self.assertEqual(len(commits), 3)
        self.assertFalse(os.path.exists(cd.worktreepath))

        commit = commits[0]
        self.assertEqual(commit['backend_name'], 'CoDep')
        self.assertEqual(commit['category'], CATEGORY_CODEP)
        result = commit['data']['analysis']
        self.assertIn('classes', result)
        self.assertTrue(type(result['classes']), dict)
        self.assertIn('nodes', result['classes'])
        self.assertTrue(type(result['classes']['nodes']), list)
        self.assertIn('links', result['classes'])
        self.assertTrue(type(result['classes']['links']), list)
        self.assertIn('packages', result)
        self.assertTrue(type(result['packages']), dict)
        self.assertTrue(type(result['packages']['nodes']), list)
        self.assertIn('links', result['packages'])
        self.assertTrue(type(result['packages']['links']), list)
Пример #2
0
    def test_fetch_unknown_category(self):
        """Test whether an exception is thrown when the category is unknown"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   tag='test')
        with self.assertRaises(GraalError):
            _ = [item for item in cd.fetch(category="unknown")]
Пример #3
0
    def test_fetch_error(self):
        """Test whether an exception is thrown when the exec_path isn't defined and the category is jadolint"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   tag='test')
        with self.assertRaises(GraalError):
            _ = [item for item in cd.fetch(category=CATEGORY_CODEP_JADOLINT)]
Пример #4
0
    def test_fetch_error(self):
        """Test whether an exception is thrown when the entrypoint isn't defined and the category is pyreverse"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   details=True,
                   tag='test')
        with self.assertRaises(GraalError):
            _ = [item for item in cd.fetch()]
Пример #5
0
    def test_fetch_empty(self):
        """Test whether no commits are returned"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   exec_path=JADOLINT_PATH,
                   in_paths=['Unknown'])
        commits = [
            commit for commit in cd.fetch(category=CATEGORY_CODEP_JADOLINT)
        ]
        self.assertEqual(commits, [])
Пример #6
0
    def test_fetch_not_existing_module(self):
        """Test whether warning messages are logged when a module is not found"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   entrypoint="unknown")

        with self.assertLogs(logger, level='WARNING') as cm:
            for commit in cd.fetch():
                self.assertRegex(
                    cm.output[-1],
                    'module path .* does not exist .* analysis will be skipped'
                )
                self.assertEqual(commit['data']['analysis'], {})
Пример #7
0
    def test_fetch(self):
        """Test whether commits are properly processed"""

        cd = CoDep('http://example.com',
                   self.git_path,
                   self.worktree_path,
                   exec_path=JADOLINT_PATH,
                   in_paths=['Dockerfile'])
        commits = [
            commit for commit in cd.fetch(category=CATEGORY_CODEP_JADOLINT)
        ]

        self.assertEqual(len(commits), 2)

        analysis = commits[0]['data']['analysis']
        self.assertIn('Dockerfile', analysis)
        expected_deps = [
            'debian stretch-slim', 'bash', 'locales', 'gcc', 'git', 'git-core',
            'python3', 'python3-pip', 'python3-venv', 'python3-dev',
            'python3-gdbm', 'mariadb-client', 'unzip', 'curl', 'wget', 'sudo',
            'ssh'
        ]
        analysis['Dockerfile'][DEPENDENCIES].sort()
        expected_deps.sort()
        self.assertListEqual(analysis['Dockerfile'][DEPENDENCIES],
                             expected_deps)

        analysis = commits[1]['data']['analysis']
        self.assertIn('Dockerfile', analysis)
        expected_deps = [
            'debian stretch-slim', 'bash', 'locales', 'gcc', 'git', 'cloc',
            'git-core', 'python3', 'python3-pip', 'python3-venv',
            'python3-dev', 'python3-gdbm', 'mariadb-client', 'unzip', 'curl',
            'wget', 'sudo', 'ssh'
        ]
        analysis['Dockerfile'][DEPENDENCIES].sort()
        expected_deps.sort()
        self.assertListEqual(analysis['Dockerfile'][DEPENDENCIES],
                             expected_deps)