def test_check_exclude_none(self): """ Test whether the check method of the DirExclude class correctly returns True for all files when no directories to be excluded are passed to the check method. """ self.assertTrue(DirExclude([]).check(self.file_gitignore)) self.assertTrue(DirExclude([]).check(self.file_perceval)) self.assertTrue(DirExclude([]).check(self.file_authors)) self.assertTrue(DirExclude([]).check(self.file_tests)) self.assertTrue(DirExclude([]).check(self.file_bin))
def test_check_exclude_perceval(self): """ Test whether the check method of the DirExclude class correctly returns False for all files in the 'perceval' directory. """ self.assertTrue(DirExclude(['perceval']).check(self.file_gitignore)) self.assertTrue(DirExclude(['perceval']).check(self.file_authors)) self.assertTrue(DirExclude(['perceval']).check(self.file_tests)) self.assertTrue(DirExclude(['perceval']).check(self.file_bin)) self.assertFalse(DirExclude(['perceval']).check(self.file_perceval))
def test_check(self): """ Test whether the check method of the DirExclude class correctly returns False for files in the `tests` and `bin` directories, which are excluded by default. """ self.assertTrue(DirExclude().check(self.file_gitignore)) self.assertTrue(DirExclude().check(self.file_perceval)) self.assertTrue(DirExclude().check(self.file_authors)) self.assertFalse(DirExclude().check(self.file_tests)) self.assertFalse(DirExclude().check(self.file_bin))
def test__flatten_DirExclude(self): """ Test whether _flatten correctly excludes commits based on DirExclude. It tests against the default value for the `dirs` parameter: ['tests', 'bin'] """ commit = CommitGit(self.items, is_code=[DirExclude()]) expected_df = CommitGit(self.items).df for index, item in expected_df.iterrows(): valid_files = [ file['file'] for file in item['files'] if all( condition.check(file['file']) for condition in commit.is_code) ] if len(valid_files) == 0: expected_df.drop(index, inplace=True) expected_df = expected_df.reset_index(drop=True) assert_frame_equal(expected_df, commit.df)
y = 'count' use_index = True return {'x': x, 'y': y, 'title': title, 'use_index': use_index} def __str__(self): return "Code Changes" if __name__ == "__main__": date_since = datetime.strptime("2018-09-07", "%Y-%m-%d") items = read_json_file('../git-commits.json') # total changes changes = CodeChangesGit(items, date_range=(date_since, None)) print("Code_Changes, total:", changes.compute()) # excluding certain files changes = CodeChangesGit(items, date_range=(date_since, None), is_code=[DirExclude(['tests']), PostfixExclude(['.md', 'COPYING'])]) print("Code_Changes, excluding some files:", changes.compute()) # considering commits only on the master changes = CodeChangesGit(items, date_range=(date_since, None), conds=[MasterInclude()]) print("Code_Changes, only for master:", changes.compute()) # time-series on a monthly basis considering only master commits print("The number of commits created on a monthly basis is:") print(changes.time_series(period='M'))