Mercurial > hg
changeset 14765:08ef6b5f3715 stable
test-wireprotocol.py: rename to test-wireproto.py for consistency
1. The module named 'wireproto' is tested.
2. There already is a test-wireproto.t for related tests on shell level.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 29 Jun 2011 13:04:00 +0200 |
parents | a7d5816087a9 |
children | 4f56b7530eab |
files | tests/test-wireproto.py tests/test-wireproto.py.out tests/test-wireprotocol.py tests/test-wireprotocol.py.out |
diffstat | 4 files changed, 47 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-wireproto.py Wed Jun 29 13:04:00 2011 +0200 @@ -0,0 +1,45 @@ +from mercurial import wireproto + +class proto(object): + def __init__(self, args): + self.args = args + def getargs(self, spec): + args = self.args + args.setdefault('*', {}) + names = spec.split() + return [args[n] for n in names] + +class clientrepo(wireproto.wirerepository): + def __init__(self, serverrepo): + self.serverrepo = serverrepo + def _call(self, cmd, **args): + return wireproto.dispatch(self.serverrepo, proto(args), cmd) + + @wireproto.batchable + def greet(self, name): + f = wireproto.future() + yield wireproto.todict(name=mangle(name)), f + yield unmangle(f.value) + +class serverrepo(object): + def greet(self, name): + return "Hello, " + name + +def mangle(s): + return ''.join(chr(ord(c) + 1) for c in s) +def unmangle(s): + return ''.join(chr(ord(c) - 1) for c in s) + +def greet(repo, proto, name): + return mangle(repo.greet(unmangle(name))) + +wireproto.commands['greet'] = (greet, 'name',) + +srv = serverrepo() +clt = clientrepo(srv) + +print clt.greet("Foobar") +b = clt.batch() +fs = [b.greet(s) for s in ["Fo, =;o", "Bar"]] +b.submit() +print [f.value for f in fs]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-wireproto.py.out Wed Jun 29 13:04:00 2011 +0200 @@ -0,0 +1,2 @@ +Hello, Foobar +['Hello, Fo, =;o', 'Hello, Bar']
--- a/tests/test-wireprotocol.py Wed Jun 29 15:00:00 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -from mercurial import wireproto - -class proto(object): - def __init__(self, args): - self.args = args - def getargs(self, spec): - args = self.args - args.setdefault('*', {}) - names = spec.split() - return [args[n] for n in names] - -class clientrepo(wireproto.wirerepository): - def __init__(self, serverrepo): - self.serverrepo = serverrepo - def _call(self, cmd, **args): - return wireproto.dispatch(self.serverrepo, proto(args), cmd) - - @wireproto.batchable - def greet(self, name): - f = wireproto.future() - yield wireproto.todict(name=mangle(name)), f - yield unmangle(f.value) - -class serverrepo(object): - def greet(self, name): - return "Hello, " + name - -def mangle(s): - return ''.join(chr(ord(c) + 1) for c in s) -def unmangle(s): - return ''.join(chr(ord(c) - 1) for c in s) - -def greet(repo, proto, name): - return mangle(repo.greet(unmangle(name))) - -wireproto.commands['greet'] = (greet, 'name',) - -srv = serverrepo() -clt = clientrepo(srv) - -print clt.greet("Foobar") -b = clt.batch() -fs = [b.greet(s) for s in ["Fo, =;o", "Bar"]] -b.submit() -print [f.value for f in fs]