@@ -50,7 +50,7 @@ def test_encode_binary_event_packet(self):
5050
5151 def test_decode_binary_event_packet (self ):
5252 pkt = packet .Packet (encoded_packet = '51-{"_placeholder":true,"num":0}' )
53- pkt .reconstruct_binary ([ b'1234' ] )
53+ self . assertTrue ( pkt .add_attachment ( b'1234' ) )
5454 self .assertEqual (pkt .packet_type , packet .BINARY_EVENT )
5555 self .assertEqual (pkt .data , b'1234' )
5656
@@ -78,7 +78,7 @@ def test_encode_binary_ack_packet(self):
7878
7979 def test_decode_binary_ack_packet (self ):
8080 pkt = packet .Packet (encoded_packet = '61-{"_placeholder":true,"num":0}' )
81- pkt .reconstruct_binary ([ b'1234' ] )
81+ self . assertTrue ( pkt .add_attachment ( b'1234' ) )
8282 self .assertEqual (pkt .packet_type , packet .BINARY_ACK )
8383 self .assertEqual (pkt .data , b'1234' )
8484
@@ -157,7 +157,8 @@ def test_decode_many_binary(self):
157157 pkt = packet .Packet (encoded_packet = (
158158 '52-{"a":"123","b":{"_placeholder":true,"num":0},'
159159 '"c":[{"_placeholder":true,"num":1},123]}' ))
160- pkt .reconstruct_binary ([b'456' , b'789' ])
160+ self .assertFalse (pkt .add_attachment (b'456' ))
161+ self .assertTrue (pkt .add_attachment (b'789' ))
161162 self .assertEqual (pkt .packet_type , packet .BINARY_EVENT )
162163 self .assertEqual (pkt .data ['a' ], '123' )
163164 self .assertEqual (pkt .data ['b' ], b'456' )
@@ -167,12 +168,21 @@ def test_decode_many_binary_ack(self):
167168 pkt = packet .Packet (encoded_packet = (
168169 '62-{"a":"123","b":{"_placeholder":true,"num":0},'
169170 '"c":[{"_placeholder":true,"num":1},123]}' ))
170- pkt .reconstruct_binary ([b'456' , b'789' ])
171+ self .assertFalse (pkt .add_attachment (b'456' ))
172+ self .assertTrue (pkt .add_attachment (b'789' ))
171173 self .assertEqual (pkt .packet_type , packet .BINARY_ACK )
172174 self .assertEqual (pkt .data ['a' ], '123' )
173175 self .assertEqual (pkt .data ['b' ], b'456' )
174176 self .assertEqual (pkt .data ['c' ], [b'789' , 123 ])
175177
178+ def test_decode_too_many_binary_packets (self ):
179+ pkt = packet .Packet (encoded_packet = (
180+ '62-{"a":"123","b":{"_placeholder":true,"num":0},'
181+ '"c":[{"_placeholder":true,"num":1},123]}' ))
182+ self .assertFalse (pkt .add_attachment (b'456' ))
183+ self .assertTrue (pkt .add_attachment (b'789' ))
184+ self .assertRaises (ValueError , pkt .add_attachment , b'123' )
185+
176186 def test_data_is_binary_list (self ):
177187 pkt = packet .Packet ()
178188 self .assertFalse (pkt ._data_is_binary ([six .text_type ('foo' )]))
0 commit comments