def test_fetch_unknown(self): """Test whether commits are properly processed""" cl = CoLang('http://example.com', self.git_path, tag="test") with self.assertRaises(GraalError): _ = cl.fetch(category="unknown")
def test_fetch_cloc(self): """Test whether commits are properly processed""" cl = CoLang('http://example.com', self.git_path, tag="test") commits = [ commit for commit in cl.fetch(category=CATEGORY_COLANG_CLOC) ] self.assertEqual(len(commits), 6) self.assertFalse(os.path.exists(cl.worktreepath)) commit = commits[0] self.assertEqual(commit['backend_name'], 'CoLang') self.assertEqual(commit['category'], CATEGORY_COLANG_CLOC) results = commit['data']['analysis'] result = results[next(iter(results))] self.assertIn('blanks', result) self.assertTrue(type(result['blanks']), int) self.assertIn('comments', result) self.assertTrue(type(result['comments']), int) self.assertIn('loc', result) self.assertTrue(type(result['loc']), int) self.assertIn('total_files', result) self.assertTrue(type(result['total_files']), int)
def test_fetch_linguist(self): """Test whether commits are properly processed""" cl = CoLang('http://example.com', self.git_path, tag="test") commits = [commit for commit in cl.fetch()] self.assertEqual(len(commits), 6) self.assertFalse(os.path.exists(cl.worktreepath)) commit = commits[0] self.assertEqual(commit['backend_name'], 'CoLang') self.assertEqual(commit['category'], CATEGORY_COLANG_LINGUIST) result = commit['data']['analysis'] self.assertNotIn('breakdown', result)
def test_initialization(self): """Test whether attributes are initializated""" cl = CoLang('http://example.com', self.git_path, self.worktree_path, tag="test") self.assertEqual(cl.uri, 'http://example.com') self.assertEqual(cl.gitpath, self.git_path) self.assertEqual(cl.repository_path, os.path.join( self.worktree_path, os.path.split(cl.gitpath)[1])) self.assertEqual(cl.origin, 'http://example.com') self.assertEqual(cl.tag, 'test')
def test_metadata_category(self): """Test metadata_category""" item = { "Author": "Nishchith Shetty <*****@*****.**>", "AuthorDate": "Tue Feb 26 22:06:31 2019 +0530", "Commit": "Nishchith Shetty <*****@*****.**>", "CommitDate": "Tue Feb 26 22:06:31 2019 +0530", "analysis": [], "analyzer": "linguist", "commit": "5866a479587e8b548b0cb2d591f3a3f5dab04443", "message": "[copyright] Update copyright dates" } self.assertEqual(CoLang.metadata_category(item), CATEGORY_COLANG_LINGUIST) item = { "Author": "Nishchith Shetty <*****@*****.**>", "AuthorDate": "Tue Feb 26 22:06:31 2019 +0530", "Commit": "Nishchith Shetty <*****@*****.**>", "CommitDate": "Tue Feb 26 22:06:31 2019 +0530", "analysis": [], "analyzer": "cloc", "commit": "5866a479587e8b548b0cb2d591f3a3f5dab04443", "message": "[copyright] Update copyright dates" } self.assertEqual(CoLang.metadata_category(item), CATEGORY_COLANG_CLOC) item = { "Author": "Nishchith Shetty <*****@*****.**>", "AuthorDate": "Tue Feb 26 22:06:31 2019 +0530", "Commit": "Nishchith Shetty <*****@*****.**>", "CommitDate": "Tue Feb 26 22:06:31 2019 +0530", "analysis": [], "analyzer": "code_language", "commit": "5866a479587e8b548b0cb2d591f3a3f5dab04443", "message": "[copyright] Update copyright dates" } with self.assertRaises(GraalError): _ = CoLang.metadata_category(item, )