From 8d1c0f81d0f5fc3c75fb5282d3712310cc2ccc65ea95b3949569fff3fd0a3cf1 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 16 Jul 2021 09:17:26 +0000 Subject: [PATCH] - Add account-defaults-redis.patch which fixes failing tests by taking into consideration redis defaults, not overwriting them (gh#andymccurdy/redis-py#1499). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-redis?expand=0&rev=58 --- account-defaults-redis.patch | 87 ++++++++++++++++++++++++++++++++++++ python-redis.changes | 7 +++ python-redis.spec | 8 ++-- 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 account-defaults-redis.patch diff --git a/account-defaults-redis.patch b/account-defaults-redis.patch new file mode 100644 index 0000000..beabd09 --- /dev/null +++ b/account-defaults-redis.patch @@ -0,0 +1,87 @@ +From fea5d60c4426ec31a0e309a2efb2be62f6b2a412 Mon Sep 17 00:00:00 2001 +From: "Chayim I. Kirshen" +Date: Mon, 28 Jun 2021 16:34:00 +0300 +Subject: [PATCH 1/3] changing unit tests to account for defaults in redis + flags + +Some versions of redis (validated against 6.2.4) set extra flags, making the tests fail. + +Modified the tests to validate the specific flags pertaining to the test case are in place. + +Similarly with acl_list, as other tests validate the specifics of acl_setuser, I changed it to validate against the acl list. + +Finally, while here, I added python 3.9 to tox +--- + tests/test_commands.py | 37 ++++++++++++++++++------------------- + 1 file changed, 18 insertions(+), 19 deletions(-) + +--- a/tests/test_commands.py ++++ b/tests/test_commands.py +@@ -105,25 +105,24 @@ class TestRedisCommands(object): + + # 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, +@@ -135,7 +134,7 @@ class TestRedisCommands(object): + 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 + +@@ -154,7 +153,7 @@ class TestRedisCommands(object): + 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 + +@@ -193,7 +192,7 @@ class TestRedisCommands(object): + + 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_setuser_categories_without_prefix_fails(self, r, request): diff --git a/python-redis.changes b/python-redis.changes index 084e70e..a9ea304 100644 --- a/python-redis.changes +++ b/python-redis.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jul 16 09:15:51 UTC 2021 - Matej Cepl + +- Add account-defaults-redis.patch which fixes failing tests by + taking into consideration redis defaults, not overwriting them + (gh#andymccurdy/redis-py#1499). + ------------------------------------------------------------------- Wed Mar 10 12:41:14 UTC 2021 - Matej Cepl diff --git a/python-redis.spec b/python-redis.spec index ccab65d..43c6392 100644 --- a/python-redis.spec +++ b/python-redis.spec @@ -25,6 +25,9 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/andymccurdy/redis-py Source: https://files.pythonhosted.org/packages/source/r/redis/redis-%{version}.tar.gz +# PATCH-FIX-UPSTREAM account-defaults-redis.patch gh#andymccurdy/redis-py#1499 mcepl@suse.com +# changing unit tests to account for defaults in redis +Patch0: account-defaults-redis.patch BuildRequires: %{python_module mock} BuildRequires: %{python_module pytest >= 2.7.0} BuildRequires: %{python_module setuptools} @@ -41,7 +44,7 @@ BuildArch: noarch The Python interface to the Redis key-value store. %prep -%setup -q -n redis-%{version} +%autosetup -p1 -n redis-%{version} %build %python_build @@ -52,8 +55,7 @@ The Python interface to the Redis key-value store. %check %{_sbindir}/redis-server --port 6379 & -# Skipped tests because of gh#andymccurdy/redis-py#1459 -%pytest -k 'not (test_acl_getuser_setuser or test_acl_list)' +%pytest killall redis-server