예제 #1
0
 def test_commit_detection(self):
     """Test that we see refs/heads/master change,
     and can read back commit messages"""
     commits = []
     deferred = find_ref(self.workd, 'refs/heads/master')
     def check_ref(hash):
         """Check the hash is the length we expect"""
         self.assertEquals(len(hash), 40)
         return get_metadata(self.workd, hash)
     deferred.addCallback(check_ref)
     def verify_metadata(data):
         """Check the message is what we expect"""
         self.assertIn('foo', data['message'])
         commits.append(data)
         return add_commit(self.workd, 'a', 'b', 'xyzzy')
     deferred.addCallback(verify_metadata)
     def check_new(commit2):
         """Stash away the second commit"""
         return find_ref(self.workd, 'refs/heads/master')
     deferred.addCallback(check_new)
     deferred.addCallback(lambda rev: get_metadata(self.workd, rev))
     def compare_commits(commit2):
         """Check the commits are like we expect"""
         commits.append(commit2)
         self.assertEquals(commits[1]['message'], 'xyzzy')
         self.assertNotEqual(commits[0]['revision'], commits[1]['revision'])
     deferred.addCallback(compare_commits)
     return deferred
예제 #2
0
 def test_commit_age(self):
     """Check that the head of master is less than 10 seconds old"""
     deferred = find_ref(self.workd, 'refs/heads/master').addCallback(
         lambda rev: get_metadata(self.workd, rev))
     def check_commit_time(metadata):
         self.failUnless(metadata['commit_time'] > time()-10)
         self.failUnless(metadata['commit_time'] < time())
     return deferred.addCallback(check_commit_time)
예제 #3
0
 def check_ref(hash):
     """Check the hash is the length we expect"""
     self.assertEquals(len(hash), 40)
     return get_metadata(self.workd, hash)