Skip to content

changing unit tests to account for defaults in redis flags #1499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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