Show More
@@ -0,0 +1,44 b'' | |||||
|
1 | from __future__ import absolute_import, print_function | |||
|
2 | ||||
|
3 | import io | |||
|
4 | import unittest | |||
|
5 | ||||
|
6 | import silenttestrunner | |||
|
7 | ||||
|
8 | from mercurial import ( | |||
|
9 | sshserver, | |||
|
10 | wireproto, | |||
|
11 | ) | |||
|
12 | ||||
|
13 | class SSHServerGetArgsTests(unittest.TestCase): | |||
|
14 | def testparseknown(self): | |||
|
15 | tests = [ | |||
|
16 | ('* 0\nnodes 0\n', ['', {}]), | |||
|
17 | ('* 0\nnodes 40\n1111111111111111111111111111111111111111\n', | |||
|
18 | ['1111111111111111111111111111111111111111', {}]), | |||
|
19 | ] | |||
|
20 | for input, expected in tests: | |||
|
21 | self.assertparse('known', input, expected) | |||
|
22 | ||||
|
23 | def assertparse(self, cmd, input, expected): | |||
|
24 | server = mockserver(input) | |||
|
25 | _func, spec = wireproto.commands[cmd] | |||
|
26 | self.assertEqual(server.getargs(spec), expected) | |||
|
27 | ||||
|
28 | def mockserver(inbytes): | |||
|
29 | ui = mockui(inbytes) | |||
|
30 | repo = mockrepo(ui) | |||
|
31 | return sshserver.sshserver(ui, repo) | |||
|
32 | ||||
|
33 | class mockrepo(object): | |||
|
34 | def __init__(self, ui): | |||
|
35 | self.ui = ui | |||
|
36 | ||||
|
37 | class mockui(object): | |||
|
38 | def __init__(self, inbytes): | |||
|
39 | self.fin = io.BytesIO(inbytes) | |||
|
40 | self.fout = io.BytesIO() | |||
|
41 | self.ferr = io.BytesIO() | |||
|
42 | ||||
|
43 | if __name__ == '__main__': | |||
|
44 | silenttestrunner.main(__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now