def checkEdges(self): conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) persons = dbm.get_project_persons(project_id) # Create map from id to name person_map = {person[0] : person[1] for person in persons} given_correct_edges = self.correct_edges if given_correct_edges[0][0] is str: # simply check the first range given_correct_edges = [self.correct_edges] release_ranges = dbm.get_release_ranges(project_id) i = -1 for correct_edges in given_correct_edges: i += 1 release_range = release_ranges[i] cluster_id = dbm.get_cluster_id(project_id, release_range) edgelist = dbm.get_edgelist(cluster_id) # Create edge list with developer names test_edges = [[person_map[edge[0]], person_map[edge[1]], edge[2]] for edge in edgelist] ## Check number of matches with known correct edges match_count = 0 for test_edge in test_edges: if test_edge in correct_edges: match_count += 1 res = (match_count == len(correct_edges)) self.assertTrue( res, msg="Project edgelist is incorrect for the v{}_release " "to v{}_release analysis!" .format(i, i+1))
def check_commit_dependency(self, commit_dependency_data): ''' Checks if the commit_dependency table contains the expected data given by self.commit_dependency in the unit test. :param commit_dependency_data: The data of the actual table: | id | commitId | file | entityId | entityType | size | impl | :return: ''' if self.commit_dependency is None: return conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) def get_commit_id(commit_hash): return dbm.getCommitId(project_id, commit_hash) # remove the "id" column # so we have (commit_id, file, entityId, type, size, impl) tuples data = [(res[1], res[2], res[3], res[4], res[5], res[6]) for res in commit_dependency_data] data_no_impl = [res[0:5] for res in data] expected_data = [(get_commit_id(res[0]), res[1], res[2], res[3], res[4], res[5]) for res in self.commit_dependency] for expected in expected_data: if expected[5] is None: # don't check the impl self.assertIn(expected[0:5], data_no_impl) else: self.assertIn(expected, data) self.assertEqual(len(data), len(expected_data))
def checkEdges(self): conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) persons = dbm.get_project_persons(project_id) # Create map from id to name person_map = {person[0]: person[1] for person in persons} given_correct_edges = self.correct_edges if given_correct_edges[0][0] is str: # simply check the first range given_correct_edges = [self.correct_edges] release_ranges = dbm.get_release_ranges(project_id) i = -1 for correct_edges in given_correct_edges: i += 1 release_range = release_ranges[i] cluster_id = dbm.get_cluster_id(project_id, release_range) edgelist = dbm.get_edgelist(cluster_id) # Create edge list with developer names test_edges = [[person_map[edge[0]], person_map[edge[1]], edge[2]] for edge in edgelist] ## Check number of matches with known correct edges match_count = 0 for test_edge in test_edges: if test_edge in correct_edges: match_count += 1 res = (match_count == len(correct_edges)) self.assertTrue( res, msg="Project edgelist is incorrect for the v{}_release " "to v{}_release analysis!".format(i, i + 1))
def getResults(self): conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) self.assertGreaterEqual(project_id, 0) results = {} for table in self.result_tables: dbm.doExec("SELECT * FROM {table}".format(table=table)) results[table] = dbm.doFetchAll() return results
def checkClean(self): conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) dbm.doExecCommit("DELETE FROM project WHERE id={}".format(project_id)) for table in pid_tables: res = dbm.doExec("SELECT * FROM {table} WHERE projectId={pid}". format(table=table, pid=project_id)) self.assertEqual(res, 0, msg="Table '{}' still dirty!". format(table)) for table in other_tables: res = dbm.doExec("SELECT * FROM {table}".format(table=table)) self.assertEqual(res, 0, msg="Table '{}' still dirty!".format(table))
def checkEdges(self): conf = Configuration.load(self.codeface_conf, self.project_conf) dbm = DBManager(conf) project_id = dbm.getProjectID(conf["project"], self.tagging) cluster_id = dbm.get_cluster_id(project_id) edgelist = dbm.get_edgelist(cluster_id) persons = dbm.get_project_persons(project_id) # Create map from id to name person_map = {person[0] : person[1] for person in persons} # Create edge list with developer names test_edges = [[person_map[edge[0]], person_map[edge[1]], edge[2]] for edge in edgelist] ## Check number of matches with known correct edges match_count = 0 for test_edge in test_edges: if test_edge in self.correct_edges: match_count += 1 res = (match_count == len(self.correct_edges)) self.assertTrue(res, msg="Project edgelist is incorrect!")