Skip to content

Commit 28559b9

Browse files
committed
test validation and skips
1 parent 6a7ed23 commit 28559b9

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@ def skip_ifmodversion_lt(min_version: str, module_name: str):
100100

101101

102102
def skip_if_redis_enterprise(func):
103-
return pytest.mark.skipif(REDIS_INFO["enterprise"] == True,
104-
reason="Redis enterprise")
103+
check = REDIS_INFO["enterprise"] is True
104+
return pytest.mark.skipif(check, reason="Redis enterprise"
105+
)
106+
107+
108+
def skip_ifnot_redis_enterprise(func):
109+
check = REDIS_INFO["enterprise"] is False
110+
return pytest.mark.skipif(check, reason="Redis enterprise")
105111

106112

107113
def _get_client(cls, request, single_connection_client=True, flushdb=True,

tests/test_commands.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def test_client_list_types_not_replica(self, r):
327327
for client_type in ['normal', 'master', 'pubsub']:
328328
clients = r.client_list(_type=client_type)
329329
assert isinstance(clients, list)
330-
330+
331331
@skip_if_redis_enterprise
332332
def test_client_list_replica(self, r):
333333
clients = r.client_list(_type='replica')
@@ -528,17 +528,12 @@ def test_config_resetstat(self, r):
528528
reset_commands_processed = int(r.info()['total_commands_processed'])
529529
assert reset_commands_processed < prior_commands_processed
530530

531+
@skip_if_redis_enterprise
531532
def test_config_set(self, r):
532-
# data = r.config_get()
533-
# rdbname = data['dbfilename']
534-
# try:
535-
# assert r.config_set('dbfilename', 'redis_py_test.rdb')
536-
# assert r.config_get()['dbfilename'] == 'redis_py_test.rdb'
537-
# finally:
538-
# assert r.config_set('dbfilename', rdbname)
539-
assert r.config_set('list-max-ziplist-entriies', 1000)
540-
assert r.config_get('list-max-ziplist-entries') == 1000
541-
r.config_set('list-max-ziplist-entriies', 0)
533+
r.config_set('timeout', 70)
534+
assert r.config_get()['timeout'] == '70'
535+
assert r.config_set('timeout', 0)
536+
assert r.config_get()['timeout'] == '0'
542537

543538
def test_dbsize(self, r):
544539
r['a'] = 'foo'

tests/test_connection_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from threading import Thread
99
from redis.connection import ssl_available, to_bool
1010
from .conftest import (
11-
skip_if_server_version_lt,
11+
skip_if_server_version_lt,
1212
skip_if_redis_enterprise,
1313
_get_client
1414
)

tests/test_monitor.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from .conftest import wait_for_command
1+
from .conftest import (
2+
skip_if_redis_enterprise,
3+
skip_ifnot_redis_enterprise,
4+
wait_for_command
5+
)
26

37

48
class TestMonitor:
@@ -40,6 +44,7 @@ def test_command_with_escaped_data(self, r):
4044
response = wait_for_command(r, m, 'GET foo\\\\x92')
4145
assert response['command'] == 'GET foo\\\\x92'
4246

47+
@skip_if_redis_enterprise
4348
def test_lua_script(self, r):
4449
with r.monitor() as m:
4550
script = 'return redis.call("GET", "foo")'
@@ -49,3 +54,11 @@ def test_lua_script(self, r):
4954
assert response['client_type'] == 'lua'
5055
assert response['client_address'] == 'lua'
5156
assert response['client_port'] == ''
57+
58+
@skip_ifnot_redis_enterprise
59+
def test_lua_script_in_enterprise(self, r):
60+
with r.monitor() as m:
61+
script = 'return redis.call("GET", "foo")'
62+
assert r.eval(script, 0) is None
63+
response = wait_for_command(r, m, 'GET foo')
64+
assert response is None

tests/test_pubsub.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import redis
88
from redis.exceptions import ConnectionError
99

10-
from .conftest import _get_client, skip_if_server_version_lt
10+
from .conftest import (
11+
_get_client,
12+
skip_if_redis_enterprise,
13+
skip_if_server_version_lt
14+
)
1115

1216

1317
def wait_for_message(pubsub, timeout=0.1, ignore_subscribe_messages=False):
@@ -528,6 +532,7 @@ def test_send_pubsub_ping_message(self, r):
528532
class TestPubSubConnectionKilled:
529533

530534
@skip_if_server_version_lt('3.0.0')
535+
@skip_if_redis_enterprise
531536
def test_connection_error_raised_when_connection_dies(self, r):
532537
p = r.pubsub()
533538
p.subscribe('foo')

tests/test_scripting.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from redis import exceptions
44

5+
from tests.conftest import skip_if_server_version_lt
6+
57

68
multiply_script = """
79
local value = redis.call('GET', KEYS[1])
@@ -30,7 +32,8 @@ def test_eval(self, r):
3032
# 2 * 3 == 6
3133
assert r.eval(multiply_script, 1, 'a', 3) == 6
3234

33-
def test_script_flush(self, r):
35+
@skip_if_server_version_lt('6.2.0')
36+
def test_script_flush_620(self, r):
3437
r.set('a', 2)
3538
r.script_load(multiply_script)
3639
r.script_flush('ASYNC')
@@ -43,6 +46,12 @@ def test_script_flush(self, r):
4346
r.script_load(multiply_script)
4447
r.script_flush()
4548

49+
with pytest.raises(exceptions.DataError):
50+
r.set('a', 2)
51+
r.script_load(multiply_script)
52+
r.script_flush("NOTREAL")
53+
54+
def test_script_flush(self, r):
4655
r.set('a', 2)
4756
r.script_load(multiply_script)
4857
r.script_flush(None)

0 commit comments

Comments
 (0)