33
33
34
34
class ConnectionTest (unittest .TestCase ):
35
35
36
- def make_connection (self ):
37
- c = Connection (DefaultEndPoint ('1.2.3.4' ))
36
+ def make_connection (self , ** kwargs ):
37
+ c = Connection (DefaultEndPoint ('1.2.3.4' ), ** kwargs )
38
38
c ._socket = Mock ()
39
39
c ._socket .send .side_effect = lambda x : len (x )
40
40
return c
@@ -186,17 +186,18 @@ def test_requested_compression_not_available(self, *args):
186
186
assert isinstance (args [0 ], ProtocolError )
187
187
188
188
def test_use_requested_compression (self , * args ):
189
- c = self .make_connection ()
189
+ c = self .make_connection (protocol_version = 4 )
190
190
c ._requests = {0 : (c ._handle_options_response , ProtocolHandler .decode_message , [])}
191
191
c .defunct = Mock ()
192
- # request LZ4 compression
193
- c .compression = "lz4 "
192
+ # request snappy compression
193
+ c .compression = "snappy "
194
194
195
195
locally_supported_compressions .pop ('lz4' , None )
196
196
locally_supported_compressions .pop ('snappy' , None )
197
197
locally_supported_compressions ['lz4' ] = ('lz4compress' , 'lz4decompress' )
198
198
locally_supported_compressions ['snappy' ] = ('snappycompress' , 'snappydecompress' )
199
199
200
+ # the server only supports snappy
200
201
options_buf = BytesIO ()
201
202
write_stringmultimap (options_buf , {
202
203
'CQL_VERSION' : ['3.0.3' ],
@@ -206,8 +207,7 @@ def test_use_requested_compression(self, *args):
206
207
207
208
c .process_msg (_Frame (version = 4 , flags = 0 , stream = 0 , opcode = SupportedMessage .opcode , body_offset = 9 , end_pos = 9 + len (options )), options )
208
209
209
-
210
- assert c .decompressor == locally_supported_compressions ['lz4' ][1 ]
210
+ assert c .decompressor == locally_supported_compressions ['snappy' ][1 ]
211
211
212
212
def test_disable_compression (self , * args ):
213
213
c = self .make_connection ()
0 commit comments