##// END OF EJS Templates
largefiles: use command executor for batch operation...
largefiles: use command executor for batch operation This is the only other user of iterbatch() in core. Tests changed because the new command executor is smart enough to not send a "batch" command over the wire if only 1 command was requested. There is still coverage for the "batch" command in this test though. Differential Revision: https://phab.mercurial-scm.org/D3270

File last commit:

r37632:a81d02ea default
r37650:6c55ce51 default
Show More
test-wireproto.py
99 lines | 2.3 KiB | text/x-python | PythonLexer
/ tests / test-wireproto.py
Pulkit Goyal
py3: make test-wireproto use print_function
r28675 from __future__ import absolute_import, print_function
Gregory Szorc
tests: use absolulte_import in test-wireproto.py
r27301
timeless
py3: use multi-line import in test-wireproto.py...
r28860 from mercurial import (
Gregory Szorc
wireproto: introduce type for raw byte responses (API)...
r36091 error,
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 pycompat,
Augie Fackler
tests: fix test-wireproto.py to work around serverrepo() not having a ui...
r36962 ui as uimod,
timeless
pycompat: switch to util.stringio for py3 compat
r28861 util,
timeless
py3: use multi-line import in test-wireproto.py...
r28860 wireproto,
Gregory Szorc
wireproto: introduce type for raw byte responses (API)...
r36091 wireprototypes,
Gregory Szorc
wireproto: move version 1 peer functionality to standalone module (API)...
r37632 wireprotov1peer,
timeless
py3: use multi-line import in test-wireproto.py...
r28860 )
timeless
pycompat: switch to util.stringio for py3 compat
r28861 stringio = util.stringio
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
class proto(object):
def __init__(self, args):
self.args = args
Gregory Szorc
wireproto: separate commands tables for version 1 and 2 commands...
r37311 self.name = 'dummyproto'
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def getargs(self, spec):
args = self.args
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 args.setdefault(b'*', {})
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 names = spec.split()
return [args[n] for n in names]
Gregory Szorc
wireproto: formalize permissions checking as part of protocol interface...
r36819 def checkperm(self, perm):
pass
Gregory Szorc
wireproto: separate commands tables for version 1 and 2 commands...
r37311 wireprototypes.TRANSPORTS['dummyproto'] = {
'transport': 'dummy',
'version': 1,
}
Gregory Szorc
wireproto: move version 1 peer functionality to standalone module (API)...
r37632 class clientpeer(wireprotov1peer.wirepeer):
Augie Fackler
tests: fix test-wireproto.py to work around serverrepo() not having a ui...
r36962 def __init__(self, serverrepo, ui):
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 self.serverrepo = serverrepo
Gregory Szorc
peer: make ui an attribute...
r37337 self.ui = ui
Gregory Szorc
wireproto: use new peer interface...
r33805
def url(self):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 return b'test'
Gregory Szorc
wireproto: use new peer interface...
r33805
def local(self):
return None
def peer(self):
return self
def canpush(self):
return True
def close(self):
pass
def capabilities(self):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 return [b'batch']
Augie Fackler
batching: migrate basic noop batching into peer.peer...
r25912
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def _call(self, cmd, **args):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 args = pycompat.byteskwargs(args)
Gregory Szorc
wireproto: introduce type for raw byte responses (API)...
r36091 res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
if isinstance(res, wireprototypes.bytesresponse):
return res.data
elif isinstance(res, bytes):
return res
else:
raise error.Abort('dummy client does not support response type')
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Augie Fackler
wireproto: make iterbatcher behave streamily over http(s)...
r28438 def _callstream(self, cmd, **args):
timeless
pycompat: switch to util.stringio for py3 compat
r28861 return stringio(self._call(cmd, **args))
Augie Fackler
wireproto: make iterbatcher behave streamily over http(s)...
r28438
Gregory Szorc
wireproto: move version 1 peer functionality to standalone module (API)...
r37632 @wireprotov1peer.batchable
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def greet(self, name):
Gregory Szorc
wireproto: move version 1 peer functionality to standalone module (API)...
r37632 f = wireprotov1peer.future()
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 yield {b'name': mangle(name)}, f
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 yield unmangle(f.value)
class serverrepo(object):
def greet(self, name):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 return b"Hello, " + name
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Pierre-Yves David
clfilter: make localpeer use a repo with "unserved" filter...
r18278 def filtered(self, name):
return self
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def mangle(s):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s))
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 def unmangle(s):
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s))
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
def greet(repo, proto, name):
return mangle(repo.greet(unmangle(name)))
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 wireproto.commands[b'greet'] = (greet, b'name',)
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
srv = serverrepo()
Augie Fackler
tests: fix test-wireproto.py to work around serverrepo() not having a ui...
r36962 clt = clientpeer(srv, uimod.ui())
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 print(clt.greet(b"Foobar"))
Gregory Szorc
peer: remove non iterating batcher (API)...
r33762 b = clt.iterbatch()
Pulkit Goyal
py3: port tests/test-wireproto.py to Python 3...
r36573 list(map(b.greet, (b'Fo, =;:<o', b'Bar')))
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 b.submit()
Gregory Szorc
peer: remove non iterating batcher (API)...
r33762 print([r for r in b.results()])