Skip to content

Commit cb97b9b

Browse files
chayimandymccurdy
andauthored
changing unit tests to account for defaults in redis flags (#1499)
Co-authored-by: Andy McCurdy <[email protected]>
1 parent fc621bd commit cb97b9b

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

tests/test_commands.py

+18-19
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,24 @@ def teardown():
108108

109109
# test enabled=False
110110
assert r.acl_setuser(username, enabled=False, reset=True)
111-
assert r.acl_getuser(username) == {
112-
'categories': ['-@all'],
113-
'commands': [],
114-
'enabled': False,
115-
'flags': ['off'],
116-
'keys': [],
117-
'passwords': [],
118-
}
111+
acl = r.acl_getuser(username)
112+
assert acl['categories'] == ['-@all']
113+
assert acl['commands'] == []
114+
assert acl['keys'] == []
115+
assert acl['passwords'] == []
116+
assert 'off' in acl['flags']
117+
assert acl['enabled'] is False
119118

120119
# test nopass=True
121120
assert r.acl_setuser(username, enabled=True, reset=True, nopass=True)
122-
assert r.acl_getuser(username) == {
123-
'categories': ['-@all'],
124-
'commands': [],
125-
'enabled': True,
126-
'flags': ['on', 'nopass'],
127-
'keys': [],
128-
'passwords': [],
129-
}
121+
acl = r.acl_getuser(username)
122+
assert acl['categories'] == ['-@all']
123+
assert acl['commands'] == []
124+
assert acl['keys'] == []
125+
assert acl['passwords'] == []
126+
assert 'on' in acl['flags']
127+
assert 'nopass' in acl['flags']
128+
assert acl['enabled'] is True
130129

131130
# test all args
132131
assert r.acl_setuser(username, enabled=True, reset=True,
@@ -138,7 +137,7 @@ def teardown():
138137
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
139138
assert set(acl['commands']) == set(['+get', '+mget', '-hset'])
140139
assert acl['enabled'] is True
141-
assert acl['flags'] == ['on']
140+
assert 'on' in acl['flags']
142141
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
143142
assert len(acl['passwords']) == 2
144143

@@ -157,7 +156,7 @@ def teardown():
157156
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
158157
assert set(acl['commands']) == set(['+get', '+mget'])
159158
assert acl['enabled'] is True
160-
assert acl['flags'] == ['on']
159+
assert 'on' in acl['flags']
161160
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
162161
assert len(acl['passwords']) == 2
163162

@@ -196,7 +195,7 @@ def teardown():
196195

197196
assert r.acl_setuser(username, enabled=False, reset=True)
198197
users = r.acl_list()
199-
assert 'user %s off -@all' % username in users
198+
assert len(users) == 2
200199

201200
@skip_if_server_version_lt(REDIS_6_VERSION)
202201
def test_acl_log(self, r, request):

tests/test_pubsub.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import threading
22
import time
33
from unittest import mock
4+
import platform
45

56
import pytest
67
import redis
@@ -547,6 +548,9 @@ def test_get_message_with_timeout_returns_none(self, r):
547548

548549

549550
class TestPubSubWorkerThread:
551+
552+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy',
553+
reason="Pypy threading issue")
550554
def test_pubsub_worker_thread_exception_handler(self, r):
551555
event = threading.Event()
552556

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ addopts = -s
33

44
[tox]
55
minversion = 2.4
6-
envlist = {py35,py36,py37,py38,pypy3}-{plain,hiredis}, flake8, covreport, codecov
6+
envlist = {py35,py36,py37,py38,py39,pypy3}-{plain,hiredis}, flake8, covreport, codecov
77

88
[testenv]
99
deps =

0 commit comments

Comments
 (0)