##// END OF EJS Templates
revlog: subclass the new `repository.iverifyproblem` Protocol class...
revlog: subclass the new `repository.iverifyproblem` Protocol class This is the same transformation as 3a90a6fd710d did for dirstate, but the CamelCase naming was already cleaned up here. We shouldn't have to explicitly subclass, but I'm doing so to test the interplay of regular attributes and the `attrs` class. Also, PyCharm has a nifty feature that puts a jump point in the gutter to navigate back and forth between the base class and subclasses (and override functions and base class functions) when there's an explicit subclassing. Additionally, PyCharm will immediately flag signature mismatches without a 40m pytype run.

File last commit:

r49801:642e31cb default
r53365:4ef6dbc2 default
Show More
test-wireproto.py
122 lines | 2.5 KiB | text/x-python | PythonLexer
/ tests / test-wireproto.py
Augie Fackler
tests: port test-wireproto.py to Python 3...
r37942 import sys
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,
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,
Gregory Szorc
wireproto: rename wireproto to wireprotov1server (API)...
r37803 wireprotov1server,
timeless
py3: use multi-line import in test-wireproto.py...
r28860 )
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.utils import stringutil
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
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
py3: use class X: instead of class X(object):...
r49801 class proto:
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 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
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
wireproto: separate commands tables for version 1 and 2 commands...
r37311 wireprototypes.TRANSPORTS['dummyproto'] = {
'transport': 'dummy',
'version': 1,
}
Augie Fackler
formatting: blacken the codebase...
r43346
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: rename wireproto to wireprotov1server (API)...
r37803 res = wireprotov1server.dispatch(self.serverrepo, proto(args), cmd)
Gregory Szorc
wireproto: introduce type for raw byte responses (API)...
r36091 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):
Valentin Gatien-Baron
wireprotov1peer: update all rpcs to use the new batchable scheme...
r48687 return {b'name': mangle(name)}, unmangle
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
py3: use class X: instead of class X(object):...
r49801 class serverrepo:
Joerg Sonnenberger
server: allow customizing the default repo filter...
r42006 def __init__(self, ui):
self.ui = ui
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765 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
Augie Fackler
formatting: blacken the codebase...
r43346
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))
Augie Fackler
formatting: blacken the codebase...
r43346
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
Augie Fackler
formatting: blacken the codebase...
r43346
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)))
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
wireproto: rename wireproto to wireprotov1server (API)...
r37803 wireprotov1server.commands[b'greet'] = (greet, b'name')
Thomas Arendsen Hein
test-wireprotocol.py: rename to test-wireproto.py for consistency...
r14765
Joerg Sonnenberger
server: allow customizing the default repo filter...
r42006 srv = serverrepo(uimod.ui())
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
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
tests: port test-wireproto.py to Python 3...
r37942 def printb(data, end=b'\n'):
out = getattr(sys.stdout, 'buffer', sys.stdout)
out.write(data + end)
out.flush()
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
tests: port test-wireproto.py to Python 3...
r37942 printb(clt.greet(b"Foobar"))
Gregory Szorc
wireproto: remove iterbatch() from peer interface (API)...
r37651
with clt.commandexecutor() as e:
fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'})
fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'})
Augie Fackler
formatting: blacken the codebase...
r43346 printb(
stringutil.pprint([f.result() for f in (fgreet1, fgreet2)], bprefix=True)
)