File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
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 not len (version_list ) 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 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+ ]
2125
2226@patch ('django_elasticache.cluster_utils.Telnet' )
2327def test_happy_path (Telnet ):
@@ -54,3 +58,20 @@ def test_prev_versions(Telnet):
5458 call (b'version\n ' ),
5559 call (b'get AmazonElastiCache:cluster\n ' ),
5660 ])
61+
62+
63+ @patch ('django_elasticache.cluster_utils.Telnet' )
64+ def test_ubuntu_protocol (Telnet ):
65+ client = Telnet .return_value
66+ client .read_until .side_effect = TEST_PROTOCOL_3
67+
68+ try :
69+ get_cluster_info ('' , 0 )
70+ except WrongProtocolData :
71+ raise AssertionError ('Raised WrongProtocolData with Ubuntu version.' )
72+
73+ client .write .assert_has_calls ([
74+ call (b'version\n ' ),
75+ call (b'config get cluster\n ' ),
76+ ])
77+
You can’t perform that action at this time.
0 commit comments