summaryrefslogtreecommitdiff
path: root/test/git/test_remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-11-02 22:39:54 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-11-02 22:39:54 +0100
commitb2ccae0d7fca3a99fc6a3f85f554d162a3fdc916 (patch)
treec040fe241af7e5e0e1f0b993b8ec08a024084b2c /test/git/test_remote.py
parent461fd06e1f2d91dfbe47168b53815086212862e4 (diff)
downloadgitpython-b2ccae0d7fca3a99fc6a3f85f554d162a3fdc916.tar.gz
Implemented PushProgress and PushInfo class including basic test cases. Now many more test-cases need to be added to be sure we can truly deal with everything git throws at us
Diffstat (limited to 'test/git/test_remote.py')
-rw-r--r--test/git/test_remote.py54
1 files changed, 48 insertions, 6 deletions
diff --git a/test/git/test_remote.py b/test/git/test_remote.py
index d97bd773..602c74cf 100644
--- a/test/git/test_remote.py
+++ b/test/git/test_remote.py
@@ -15,19 +15,39 @@ import random
random.seed(0)
class TestPushProgress(PushProgress):
+ __slots__ = ( "_seen_lines", "_stages_per_op" )
def __init__(self):
- self._seen_ops = 0
+ super(TestPushProgress, self).__init__()
+ self._seen_lines = 0
self._stages_per_op = dict()
+ def _parse_progress_line(self, line):
+ super(TestPushProgress, self)._parse_progress_line(line)
+ assert len(line) > 1, "line %r too short" % line
+ self._seen_lines += 1
+
def line_dropped(self, line):
- print line
+ pass
- def update(self, op_code, cur_count, max_count=None):
+ def update(self, op_code, cur_count, max_count=None, message=''):
# check each stage only comes once
- pass
+ op_id = op_code & self.OP_MASK
+ assert op_id in (self.COUNTING, self.COMPRESSING, self.WRITING)
+
+ self._stages_per_op.setdefault(op_id, 0)
+ self._stages_per_op[ op_id ] = self._stages_per_op[ op_id ] | (op_code & self.STAGE_MASK)
+
+ if op_code & (self.WRITING|self.END) == (self.WRITING|self.END):
+ assert message
+ # END check we get message
def make_assertion(self):
- assert self._seen_ops == 3
+ if not self._seen_lines:
+ return
+
+ assert len(self._seen_ops) == 3
+ assert self._stages_per_op
+
# must have seen all stages
for op, stages in self._stages_per_op.items():
assert stages & self.STAGE_MASK == self.STAGE_MASK
@@ -56,6 +76,26 @@ class TestRemote(TestBase):
# END forced update checking
# END for each info
+ def _test_push_result(self, results, remote):
+ assert len(results) > 0 and isinstance(results[0], PushInfo)
+ for info in results:
+ assert info.flags
+ if info.old_commit is not None:
+ assert isinstance(info.old_commit, Commit)
+ if info.flags & info.ERROR:
+ has_one = False
+ for bitflag in (info.REJECTED, info.REMOTE_REJECTED, info.REMOTE_FAILURE):
+ has_one |= bool(info.flags & bitflag)
+ # END for each bitflag
+ assert has_one
+ else:
+ # there must be a remote commit
+ assert isinstance(info.local_ref, Reference)
+ assert type(info.remote_ref) in (TagReference, RemoteReference)
+ # END error checking
+ # END for each info
+
+
def _test_fetch_info(self, repo):
self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "nonsense", '')
self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "? [up to date] 0.1.7RC -> origin/0.1.7RC", '')
@@ -196,15 +236,17 @@ class TestRemote(TestBase):
lhead.reset(remote.refs.master, working_tree=True)
# push without spec should fail ( without further configuration )
- # well, works
+ # well, works nicely
# self.failUnlessRaises(GitCommandError, remote.push)
self._commit_random_file(rw_repo)
progress = TestPushProgress()
res = remote.push(lhead.reference, progress)
assert isinstance(res, IterableList)
+ self._test_push_result(res, remote)
progress.make_assertion()
+
self.fail("test --all")
self.fail("test rewind and force -push")
self.fail("test general fail due to invalid refspec")