author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Thu, 08 Jul 2021 00:57:25 +0200 | |
changeset 47595 | 14e2f4bd5f16 |
parent 45957 | 89a2afe31e82 |
child 48966 | 6000f5b25c9b |
permissions | -rw-r--r-- |
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 |
from __future__ import absolute_import, print_function |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
|
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
import unittest |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
|
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
from mercurial import ( |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
util, |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
wireprotoframing as framing, |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
) |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
|
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
ffs = framing.makeframefromhumanstring |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
12 |
|
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
13 |
class FrameHumanStringTests(unittest.TestCase): |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
14 |
def testbasic(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
15 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
16 |
ffs(b'1 1 0 1 0 '), b'\x00\x00\x00\x01\x00\x01\x00\x10' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
17 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
18 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
19 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
20 |
ffs(b'2 4 0 1 0 '), b'\x00\x00\x00\x02\x00\x04\x00\x10' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
21 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
22 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
23 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
24 |
ffs(b'2 4 0 1 0 foo'), b'\x03\x00\x00\x02\x00\x04\x00\x10foo' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
25 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
26 |
|
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
27 |
def testcborint(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
28 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
29 |
ffs(b'1 1 0 1 0 cbor:15'), b'\x01\x00\x00\x01\x00\x01\x00\x10\x0f' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
30 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
31 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
32 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
33 |
ffs(b'1 1 0 1 0 cbor:42'), b'\x02\x00\x00\x01\x00\x01\x00\x10\x18*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
34 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
35 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
36 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
37 |
ffs(b'1 1 0 1 0 cbor:1048576'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
38 |
b'\x05\x00\x00\x01\x00\x01\x00\x10\x1a' b'\x00\x10\x00\x00', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
39 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
40 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
41 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
42 |
ffs(b'1 1 0 1 0 cbor:0'), b'\x01\x00\x00\x01\x00\x01\x00\x10\x00' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
43 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
44 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
45 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
46 |
ffs(b'1 1 0 1 0 cbor:-1'), b'\x01\x00\x00\x01\x00\x01\x00\x10 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
47 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
48 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
49 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
50 |
ffs(b'1 1 0 1 0 cbor:-342542'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
51 |
b'\x05\x00\x00\x01\x00\x01\x00\x10:\x00\x05:\r', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
52 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
53 |
|
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
54 |
def testcborstrings(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
55 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
56 |
ffs(b"1 1 0 1 0 cbor:b'foo'"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
57 |
b'\x04\x00\x00\x01\x00\x01\x00\x10Cfoo', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
58 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
59 |
|
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
60 |
def testcborlists(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
61 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
62 |
ffs(b"1 1 0 1 0 cbor:[None, True, False, 42, b'foo']"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
63 |
b'\n\x00\x00\x01\x00\x01\x00\x10\x85\xf6\xf5\xf4' b'\x18*Cfoo', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
64 |
) |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
65 |
|
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
66 |
def testcbordicts(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
67 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
68 |
ffs(b"1 1 0 1 0 " b"cbor:{b'foo': b'val1', b'bar': b'val2'}"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
69 |
b'\x13\x00\x00\x01\x00\x01\x00\x10\xa2' b'CbarDval2CfooDval1', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
70 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
71 |
|
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37289
diff
changeset
|
72 |
|
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 |
class FrameTests(unittest.TestCase): |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
def testdataexactframesize(self): |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
data = util.bytesio(b'x' * framing.DEFAULT_MAX_FRAME_SIZE) |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 |
|
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
77 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
78 |
frames = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
79 |
framing.createcommandframes(stream, 1, b'command', {}, data) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
80 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
81 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
82 |
frames, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
83 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
84 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
85 |
b'1 1 stream-begin command-request new|have-data ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
86 |
b"cbor:{b'name': b'command'}" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
87 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
88 |
ffs(b'1 1 0 command-data continuation %s' % data.getvalue()), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
89 |
ffs(b'1 1 0 command-data eos '), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
90 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
91 |
) |
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 |
|
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 |
def testdatamultipleframes(self): |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 |
data = util.bytesio(b'x' * (framing.DEFAULT_MAX_FRAME_SIZE + 1)) |
37287
3ed344546d9e
wireproto: start to associate frame generation with a stream
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37286
diff
changeset
|
95 |
|
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
96 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
97 |
frames = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
98 |
framing.createcommandframes(stream, 1, b'command', {}, data) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
99 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
100 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
101 |
frames, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
102 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
103 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
104 |
b'1 1 stream-begin command-request new|have-data ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
105 |
b"cbor:{b'name': b'command'}" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
106 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
107 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
108 |
b'1 1 0 command-data continuation %s' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
109 |
% (b'x' * framing.DEFAULT_MAX_FRAME_SIZE) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
110 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
111 |
ffs(b'1 1 0 command-data eos x'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
112 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
113 |
) |
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 |
|
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 |
def testargsanddata(self): |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 |
data = util.bytesio(b'x' * 100) |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 |
|
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
118 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
119 |
frames = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
120 |
framing.createcommandframes( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
121 |
stream, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
122 |
1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
123 |
b'command', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
124 |
{ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
125 |
b'key1': b'key1value', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
126 |
b'key2': b'key2value', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
127 |
b'key3': b'key3value', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
128 |
}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
129 |
data, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
130 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
131 |
) |
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
133 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
134 |
frames, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
135 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
136 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
137 |
b'1 1 stream-begin command-request new|have-data ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
138 |
b"cbor:{b'name': b'command', b'args': {b'key1': b'key1value', " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
139 |
b"b'key2': b'key2value', b'key3': b'key3value'}}" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
140 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
141 |
ffs(b'1 1 0 command-data eos %s' % data.getvalue()), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
142 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
143 |
) |
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
|
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
145 |
if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
146 |
# Python 3.7 deprecates the regex*p* version, but 2.7 lacks |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
147 |
# the regex version. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
148 |
assertRaisesRegex = ( # camelcase-required |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
149 |
unittest.TestCase.assertRaisesRegexp |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
150 |
) |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
151 |
|
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
152 |
def testtextoutputformattingstringtype(self): |
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
153 |
"""Formatting string must be bytes.""" |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
154 |
with self.assertRaisesRegex(ValueError, 'must use bytes formatting '): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
155 |
list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
156 |
framing.createtextoutputframe( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
157 |
None, 1, [(b'foo'.decode('ascii'), [], [])] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
158 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
159 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
160 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
161 |
def testtextoutputargumentbytes(self): |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
162 |
with self.assertRaisesRegex(ValueError, 'must use bytes for argument'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
163 |
list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
164 |
framing.createtextoutputframe( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
165 |
None, 1, [(b'foo', [b'foo'.decode('ascii')], [])] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
166 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
167 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
168 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
169 |
def testtextoutputlabelbytes(self): |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37542
diff
changeset
|
170 |
with self.assertRaisesRegex(ValueError, 'must use bytes for labels'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
171 |
list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
172 |
framing.createtextoutputframe( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
173 |
None, 1, [(b'foo', [], [b'foo'.decode('ascii')])] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
174 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
175 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
176 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
177 |
def testtextoutput1simpleatom(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
178 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
179 |
val = list(framing.createtextoutputframe(stream, 1, [(b'foo', [], [])])) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
180 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
181 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
182 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
183 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
184 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
185 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
186 |
b"cbor:[{b'msg': b'foo'}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
187 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
188 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
189 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
190 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
191 |
def testtextoutput2simpleatoms(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
192 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
193 |
val = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
194 |
framing.createtextoutputframe( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
195 |
stream, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
196 |
1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
197 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
198 |
(b'foo', [], []), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
199 |
(b'bar', [], []), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
200 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
201 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
202 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
203 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
204 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
205 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
206 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
207 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
208 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
209 |
b"cbor:[{b'msg': b'foo'}, {b'msg': b'bar'}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
210 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
211 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
212 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
213 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
214 |
def testtextoutput1arg(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
215 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
216 |
val = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
217 |
framing.createtextoutputframe( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
218 |
stream, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
219 |
1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
220 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
221 |
(b'foo %s', [b'val1'], []), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
222 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
223 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
224 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
225 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
226 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
227 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
228 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
229 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
230 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
231 |
b"cbor:[{b'msg': b'foo %s', b'args': [b'val1']}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
232 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
233 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
234 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
235 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
236 |
def testtextoutput2arg(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
237 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
238 |
val = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
239 |
framing.createtextoutputframe( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
240 |
stream, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
241 |
1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
242 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
243 |
(b'foo %s %s', [b'val', b'value'], []), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
244 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
245 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
246 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
247 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
248 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
249 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
250 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
251 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
252 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
253 |
b"cbor:[{b'msg': b'foo %s %s', b'args': [b'val', b'value']}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
254 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
255 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
256 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
257 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
258 |
def testtextoutput1label(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
259 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
260 |
val = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
261 |
framing.createtextoutputframe( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
262 |
stream, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
263 |
1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
264 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
265 |
(b'foo', [], [b'label']), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
266 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
267 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
268 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
269 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
270 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
271 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
272 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
273 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
274 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
275 |
b"cbor:[{b'msg': b'foo', b'labels': [b'label']}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
276 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
277 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
278 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
279 |
|
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
280 |
def testargandlabel(self): |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37287
diff
changeset
|
281 |
stream = framing.stream(1) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
282 |
val = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
283 |
framing.createtextoutputframe( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
284 |
stream, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
285 |
1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
286 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
287 |
(b'foo %s', [b'arg'], [b'label']), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
288 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
289 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
290 |
) |
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
291 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
292 |
self.assertEqual( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
293 |
val, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
294 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
295 |
ffs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
296 |
b'1 1 stream-begin text-output 0 ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
297 |
b"cbor:[{b'msg': b'foo %s', b'args': [b'arg'], " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
298 |
b"b'labels': [b'label']}]" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
299 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
300 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
301 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
302 |
|
37063
0a6c5cc09a88
wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37061
diff
changeset
|
303 |
|
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
304 |
if __name__ == '__main__': |
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
305 |
import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39437
diff
changeset
|
306 |
|
37055
8c3c47362934
wireproto: implement basic frame reading and processing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
307 |
silenttestrunner.main(__name__) |