Skip to content

Commit f4b5e65

Browse files
committed
Merge branch 'zbmott-master'
2 parents faf5cc7 + 584ba46 commit f4b5e65

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

django_elasticache/cluster_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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'):

django_elasticache/memcached.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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,

tests/test_protocol.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
b'CONFIG cluster 0 138\r\n1\nhost|ip|port host||port\n\r\nEND\r\n',
1919
]
2020

21+
TEST_PROTOCOL_3 = [
22+
b'VERSION 1.4.14 (Ubuntu)',
23+
b'CONFIG cluster 0 138\r\n1\nhost|ip|port host||port\n\r\nEND\r\n',
24+
]
25+
2126

2227
@patch('django_elasticache.cluster_utils.Telnet')
2328
def 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+
])

0 commit comments

Comments
 (0)