def testBasic(self): """Test get_commit_timestamps works with good timestamps.""" commits = [ uprev_frequency.Commit('abc', '123', 'foo'), uprev_frequency.Commit('def', '456', 'bar'), ] timestamps = uprev_frequency.get_commit_timestamps(commits) self.assertEqual(timestamps, [123, 456])
def testMixed(self): """Test get_uprev_commits with mixed input.""" uprev_commit = uprev_frequency.Commit( 'abc', '123', cros_mark_as_stable.GIT_COMMIT_SUBJECT) commits = [ uprev_commit, uprev_frequency.Commit('def', '456', 'not an uprev commit'), ] self.assertEqual(uprev_frequency.get_uprev_commits(commits), [uprev_commit])
def testCommitParsing(self): """Test get_directory_commits when log outputs commits.""" log_lines = [ 'abc|123|foo', 'def|456|bar', ] log_output = '\n'.join(log_lines) self.PatchObject(git, 'Log', return_value=log_output) commits = uprev_frequency.get_directory_commits('foo/bar') self.assertEqual(commits, [ uprev_frequency.Commit('abc', '123', 'foo'), uprev_frequency.Commit('def', '456', 'bar'), ])
def testMalformed(self): """Test get_commit_timestamps explodes on malformed timestamp.""" self.assertRaises(ValueError, uprev_frequency.get_commit_timestamps, [uprev_frequency.Commit('abc', 'bad-timestamp', 'foo')])