def testAuthorAddActiveDay(self): author = self.getTestAuthor() active_days = author[AuthorDictFactory.ACTIVE_DAYS] day_count = active_days.__len__() AuthorDictFactory.add_active_day(author, '2000.01.01') self.assertEqual(author[AuthorDictFactory.ACTIVE_DAYS].__len__(), day_count + 1) self.assertTrue('2000.01.01' in author[AuthorDictFactory.ACTIVE_DAYS])
def testAuthorCheckFirstCommit(self): author = self.getTestAuthor() init = author[AuthorDictFactory.FIRST_COMMIT] # expected: first_commit not change AuthorDictFactory.check_first_commit_stamp(author, init + 1000) self.assertEqual(author[AuthorDictFactory.FIRST_COMMIT], init) # expected: first_commit change to the earlier timestamp AuthorDictFactory.check_first_commit_stamp(author, init - 1000) self.assertEqual(author[AuthorDictFactory.FIRST_COMMIT], init - 1000)
def testAuthorLastCommit(self): author = self.getTestAuthor() init = author[AuthorDictFactory.LAST_COMMIT] last_commit_after = datetime.datetime.strptime('2019-03-20', '%Y-%m-%d') last_commit_before = datetime.datetime.strptime( '2019-03-10', '%Y-%m-%d') # expected: first_commit not change AuthorDictFactory.check_last_commit_stamp( author, last_commit_before.timestamp()) self.assertEqual(author[AuthorDictFactory.LAST_COMMIT], init) # expected: first_commit change to the earlier timestamp AuthorDictFactory.check_last_commit_stamp( author, last_commit_after.timestamp()) self.assertEqual(author[AuthorDictFactory.LAST_COMMIT], last_commit_after.timestamp()) self.assertEqual(author[AuthorDictFactory.LAST_ACTIVE_DAY], '2019-03-20')
def testAuthorLinesAdd(self): author = self.getTestAuthor() init = author[AuthorDictFactory.LINES_ADDED] AuthorDictFactory.add_lines_added(author, 10) self.assertEqual(author[AuthorDictFactory.LINES_ADDED], init + 10)
def create_test_author(data): return AuthorDictFactory.create_author( data['author_name'], data['lines_removed'], data['lines_added'], data['active_days'], data['commits'], data['first_commit_ts'], data['last_commit_ts'])
def testAuthorLinesCommit(self): author = self.getTestAuthor() init = author[AuthorDictFactory.COMMITS] AuthorDictFactory.add_commit(author, 10) self.assertEqual(author[AuthorDictFactory.COMMITS], init + 10)
def testAuthorLinesRemoved(self): author = self.getTestAuthor() init = author[AuthorDictFactory.LINES_REMOVED] AuthorDictFactory.add_lines_removed(author, 13) self.assertEqual(author[AuthorDictFactory.LINES_REMOVED], init + 13)