Skip to content

Commit

Permalink
changing unit tests to account for defaults in redis flags (#1499)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy McCurdy <andy@andymccurdy.com>
  • Loading branch information
chayim and andymccurdy committed Jul 15, 2021
1 parent fc621bd commit cb97b9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
37 changes: 18 additions & 19 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,24 @@ def teardown():

# test enabled=False
assert r.acl_setuser(username, enabled=False, reset=True)
assert r.acl_getuser(username) == {
'categories': ['-@all'],
'commands': [],
'enabled': False,
'flags': ['off'],
'keys': [],
'passwords': [],
}
acl = r.acl_getuser(username)
assert acl['categories'] == ['-@all']
assert acl['commands'] == []
assert acl['keys'] == []
assert acl['passwords'] == []
assert 'off' in acl['flags']
assert acl['enabled'] is False

# test nopass=True
assert r.acl_setuser(username, enabled=True, reset=True, nopass=True)
assert r.acl_getuser(username) == {
'categories': ['-@all'],
'commands': [],
'enabled': True,
'flags': ['on', 'nopass'],
'keys': [],
'passwords': [],
}
acl = r.acl_getuser(username)
assert acl['categories'] == ['-@all']
assert acl['commands'] == []
assert acl['keys'] == []
assert acl['passwords'] == []
assert 'on' in acl['flags']
assert 'nopass' in acl['flags']
assert acl['enabled'] is True

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

Expand All @@ -157,7 +156,7 @@ def teardown():
assert set(acl['categories']) == set(['-@all', '+@set', '+@hash'])
assert set(acl['commands']) == set(['+get', '+mget'])
assert acl['enabled'] is True
assert acl['flags'] == ['on']
assert 'on' in acl['flags']
assert set(acl['keys']) == set([b'cache:*', b'objects:*'])
assert len(acl['passwords']) == 2

Expand Down Expand Up @@ -196,7 +195,7 @@ def teardown():

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

@skip_if_server_version_lt(REDIS_6_VERSION)
def test_acl_log(self, r, request):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pubsub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import threading
import time
from unittest import mock
import platform

import pytest
import redis
Expand Down Expand Up @@ -547,6 +548,9 @@ def test_get_message_with_timeout_returns_none(self, r):


class TestPubSubWorkerThread:

@pytest.mark.skipif(platform.python_implementation() == 'PyPy',
reason="Pypy threading issue")
def test_pubsub_worker_thread_exception_handler(self, r):
event = threading.Event()

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ addopts = -s

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

[testenv]
deps =
Expand Down

0 comments on commit cb97b9b

Please sign in to comment.