class ConnectedTest(unittest.TestCase): def setUp(self): self.connection = GitHubConnection(user="******", repo="GitHubResearchDataMiner") def testChoke(self): self.connection._GitHubConnection__choke() alpha = HelperFunctions.millitimestamp() self.connection._GitHubConnection__choke() delta = HelperFunctions.millitimestamp() self.assertGreater( delta, alpha + 79, "The choke delay is less than 0.08 seconds: " + str( (delta - alpha) / 1000) + " (" + str(delta) + ")") self.assertLess( delta, alpha + 90, "The choke delay is too much over 0.08 seconds: " + str( (delta - alpha) / 1000) + " (" + str(delta) + ")") # issue #2 Draw commit logs for a repository in GitHub def testGitHubConnection(self): commits = self.connection.getCommitMessages() validFlag = commits.count('\n') > 2 self.assertTrue(validFlag, "Cannot draw commit logs from GitHub") def testGitTreeFileSize(self): tree = self.connection.repo.get_git_tree( "09981dc5c4faf51c6b2713d345d9038f5282f269", False) for treeElement in tree.tree: #print ("Tree-element: "+treeElement.path+":"+str(treeElement.size)) if treeElement.path == "src/config.cfg": self.assertEqual( treeElement.size, 115, "Failed to assert correct file size at given revision.") # issue #1 Produce CSV file of all commit data of a given repository def testProduceCSVfile(self): filepath = self.connection.getCsv() fileh = open(filepath, 'r') for line in fileh: self.assertGreater(line.count(';'), 1, "Produced file is not CSV: " + line) fileh.close() os.remove(filepath)
class ConnectedTest(unittest.TestCase): def setUp(self): self.connection = GitHubConnection(user="******", repo="GitHubResearchDataMiner") def testChoke(self): self.connection._GitHubConnection__choke() alpha = HelperFunctions.millitimestamp() self.connection._GitHubConnection__choke() delta = HelperFunctions.millitimestamp() self.assertGreater( delta, alpha + 79, "The choke delay is less than 0.08 seconds: " + str((delta - alpha) / 1000) + " (" + str(delta) + ")", ) self.assertLess( delta, alpha + 90, "The choke delay is too much over 0.08 seconds: " + str((delta - alpha) / 1000) + " (" + str(delta) + ")", ) # issue #2 Draw commit logs for a repository in GitHub def testGitHubConnection(self): commits = self.connection.getCommitMessages() validFlag = commits.count("\n") > 2 self.assertTrue(validFlag, "Cannot draw commit logs from GitHub") def testGitTreeFileSize(self): tree = self.connection.repo.get_git_tree("09981dc5c4faf51c6b2713d345d9038f5282f269", False) for treeElement in tree.tree: # print ("Tree-element: "+treeElement.path+":"+str(treeElement.size)) if treeElement.path == "src/config.cfg": self.assertEqual(treeElement.size, 115, "Failed to assert correct file size at given revision.") # issue #1 Produce CSV file of all commit data of a given repository def testProduceCSVfile(self): filepath = self.connection.getCsv() fileh = open(filepath, "r") for line in fileh: self.assertGreater(line.count(";"), 1, "Produced file is not CSV: " + line) fileh.close() os.remove(filepath)
def setUp(self): self.connection = GitHubConnection(user="******", repo="GitHubResearchDataMiner")