File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def get_cluster_info(host, port):
3232 client .write (b'version\n ' )
3333 res = client .read_until (b'\r \n ' ).strip ()
3434 version_list = res .split (b' ' )
35- if len (version_list ) != 2 or version_list [0 ] != b'VERSION' :
35+ if len (version_list ) not in [ 2 , 3 ] or version_list [0 ] != b'VERSION' :
3636 raise WrongProtocolData ('version' , res )
3737 version = version_list [1 ]
3838 if StrictVersion (smart_text (version )) >= StrictVersion ('1.4.14' ):
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def update_params(self, params):
4747 ' in binary mode' )
4848 else :
4949 params ['BINARY' ] = True # patch params, set binary mode
50- if not 'OPTIONS' in params :
50+ if 'OPTIONS' not in params :
5151 # set special 'behaviors' pylibmc attributes
5252 params ['OPTIONS' ] = {
5353 'tcp_nodelay' : True ,
Original file line number Diff line number Diff line change 1818 b'CONFIG cluster 0 138\r \n 1\n host|ip|port host||port\n \r \n END\r \n ' ,
1919]
2020
21+ TEST_PROTOCOL_3 = [
22+ b'VERSION 1.4.14 (Ubuntu)' ,
23+ b'CONFIG cluster 0 138\r \n 1\n host|ip|port host||port\n \r \n END\r \n ' ,
24+ ]
25+
2126
2227@patch ('django_elasticache.cluster_utils.Telnet' )
2328def test_happy_path (Telnet ):
@@ -54,3 +59,19 @@ def test_prev_versions(Telnet):
5459 call (b'version\n ' ),
5560 call (b'get AmazonElastiCache:cluster\n ' ),
5661 ])
62+
63+
64+ @patch ('django_elasticache.cluster_utils.Telnet' )
65+ def test_ubuntu_protocol (Telnet ):
66+ client = Telnet .return_value
67+ client .read_until .side_effect = TEST_PROTOCOL_3
68+
69+ try :
70+ get_cluster_info ('' , 0 )
71+ except WrongProtocolData :
72+ raise AssertionError ('Raised WrongProtocolData with Ubuntu version.' )
73+
74+ client .write .assert_has_calls ([
75+ call (b'version\n ' ),
76+ call (b'config get cluster\n ' ),
77+ ])
You can’t perform that action at this time.
0 commit comments