Skip to content

Commit

Permalink
Merge pull request #8 from mkmkme/mkmkme/remove-old-valkey
Browse files Browse the repository at this point in the history
Remove mentions and workarounds for older Redis versions
  • Loading branch information
aiven-sal authored May 29, 2024
2 parents fdc01c5 + ebbc1d4 commit 561edfb
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 731 deletions.
4 changes: 2 additions & 2 deletions docs/lua_scripting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ key, multiplies it with the multiplier value and returns the result.

.. code:: python
>>> r = redis.Redis()
>>> r = valkey.Valkey()
>>> lua = """
... local value = redis.call('GET', KEYS[1])
... value = tonumber(value)
Expand Down Expand Up @@ -62,7 +62,7 @@ one that points to a completely different Valkey server.

.. code:: python
>>> r2 = redis.Redis('valkey2.example.com')
>>> r2 = valkey.Valkey('valkey2.example.com')
>>> r2.set('foo', 3)
>>> multiply(keys=['foo'], args=[5], client=r2)
15
Expand Down
83 changes: 0 additions & 83 deletions tests/test_asyncio/test_cluster.py

Large diffs are not rendered by default.

145 changes: 0 additions & 145 deletions tests/test_asyncio/test_commands.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions tests/test_asyncio/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import pytest
import valkey
from tests.conftest import skip_if_server_version_lt
from valkey._parsers import (
_AsyncHiredisParser,
_AsyncRESP2Parser,
Expand Down Expand Up @@ -90,7 +89,6 @@ async def get_conn(_):
await r.aclose()


@skip_if_server_version_lt("4.0.0")
@pytest.mark.valkeymod
@pytest.mark.onlynoncluster
async def test_loading_external_modules(r):
Expand Down
16 changes: 5 additions & 11 deletions tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pytest
import pytest_asyncio
import valkey.asyncio as valkey
from tests.conftest import skip_if_server_version_lt
from valkey.asyncio.connection import Connection, to_bool

from .compat import aclosing, mock
Expand Down Expand Up @@ -318,13 +317,11 @@ def test_port(self):
assert pool.connection_class == valkey.Connection
assert pool.connection_kwargs == {"host": "localhost", "port": 6380}

@skip_if_server_version_lt("6.0.0")
def test_username(self):
pool = valkey.ConnectionPool.from_url("valkey://myuser:@localhost")
assert pool.connection_class == valkey.Connection
assert pool.connection_kwargs == {"host": "localhost", "username": "myuser"}

@skip_if_server_version_lt("6.0.0")
def test_quoted_username(self):
pool = valkey.ConnectionPool.from_url(
"valkey://%2Fmyuser%2F%2B name%3D%24+:@localhost"
Expand All @@ -350,7 +347,6 @@ def test_quoted_password(self):
"password": "/mypass/+ word=$+",
}

@skip_if_server_version_lt("6.0.0")
def test_username_and_password(self):
pool = valkey.ConnectionPool.from_url("valkey://myuser:mypass@localhost")
assert pool.connection_class == valkey.Connection
Expand Down Expand Up @@ -477,13 +473,11 @@ def test_defaults(self):
assert pool.connection_class == valkey.UnixDomainSocketConnection
assert pool.connection_kwargs == {"path": "/socket"}

@skip_if_server_version_lt("6.0.0")
def test_username(self):
pool = valkey.ConnectionPool.from_url("unix://myuser:@/socket")
assert pool.connection_class == valkey.UnixDomainSocketConnection
assert pool.connection_kwargs == {"path": "/socket", "username": "myuser"}

@skip_if_server_version_lt("6.0.0")
def test_quoted_username(self):
pool = valkey.ConnectionPool.from_url(
"unix://%2Fmyuser%2F%2B name%3D%24+:@/socket"
Expand Down Expand Up @@ -587,7 +581,6 @@ async def test_on_connect_error(self):
assert not pool._available_connections[0]._reader

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.8.8")
async def test_busy_loading_disconnects_socket(self, r):
"""
If Valkey raises a LOADING error, the connection should be
Expand All @@ -599,7 +592,6 @@ async def test_busy_loading_disconnects_socket(self, r):
assert not r.connection._reader

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.8.8")
async def test_busy_loading_from_pipeline_immediate_command(self, r):
"""
BusyLoadingErrors should raise from Pipelines that execute a
Expand All @@ -616,7 +608,6 @@ async def test_busy_loading_from_pipeline_immediate_command(self, r):
assert not pool._available_connections[0]._reader

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.8.8")
async def test_busy_loading_from_pipeline(self, r):
"""
BusyLoadingErrors should be raised from a pipeline execution
Expand All @@ -631,7 +622,6 @@ async def test_busy_loading_from_pipeline(self, r):
assert len(pool._available_connections) == 1
assert not pool._available_connections[0]._reader

@skip_if_server_version_lt("2.8.8")
async def test_read_only_error(self, r):
"""READONLY errors get turned into ReadOnlyError exceptions"""
with pytest.raises(valkey.ReadOnlyError):
Expand Down Expand Up @@ -676,7 +666,11 @@ async def test_connect_no_auth_supplied_when_required(self, r):
"""
with pytest.raises(valkey.AuthenticationError):
await r.execute_command(
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
"DEBUG",
"ERROR",
"ERR AUTH <password> called without any password "
"configured for the default user. Are you sure "
"your configuration is correct?",
)

async def test_connect_invalid_password_supplied(self, r):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_asyncio/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import valkey
from tests.conftest import skip_if_server_version_lt

from .compat import aclosing, mock
from .conftest import wait_for_command
Expand Down Expand Up @@ -393,7 +392,6 @@ async def test_pipeline_get(self, r):
assert await pipe.execute() == [b"a1"]

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.0.0")
async def test_pipeline_discard(self, r):
# empty pipeline should raise an error
async with r.pipeline() as pipe:
Expand Down
8 changes: 1 addition & 7 deletions tests/test_asyncio/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pytest
import pytest_asyncio
import valkey.asyncio as valkey
from tests.conftest import get_protocol_version, skip_if_server_version_lt
from tests.conftest import get_protocol_version
from valkey.exceptions import ConnectionError
from valkey.typing import EncodableT
from valkey.utils import HIREDIS_AVAILABLE
Expand Down Expand Up @@ -608,7 +608,6 @@ async def test_channel_subscribe(self, r: valkey.Valkey):
@pytest.mark.onlynoncluster
class TestPubSubSubcommands:
@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.8.0")
async def test_pubsub_channels(self, r: valkey.Valkey, pubsub):
p = pubsub
await p.subscribe("foo", "bar", "baz", "quux")
Expand All @@ -618,7 +617,6 @@ async def test_pubsub_channels(self, r: valkey.Valkey, pubsub):
assert all([channel in await r.pubsub_channels() for channel in expected])

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.8.0")
async def test_pubsub_numsub(self, r: valkey.Valkey):
p1 = r.pubsub()
await p1.subscribe("foo", "bar", "baz")
Expand All @@ -638,7 +636,6 @@ async def test_pubsub_numsub(self, r: valkey.Valkey):
await p2.aclose()
await p3.aclose()

@skip_if_server_version_lt("2.8.0")
async def test_pubsub_numpat(self, r: valkey.Valkey):
p = r.pubsub()
await p.psubscribe("*oo", "*ar", "b*z")
Expand All @@ -650,7 +647,6 @@ async def test_pubsub_numpat(self, r: valkey.Valkey):

@pytest.mark.onlynoncluster
class TestPubSubPings:
@skip_if_server_version_lt("3.0.0")
async def test_send_pubsub_ping(self, r: valkey.Valkey):
p = r.pubsub(ignore_subscribe_messages=True)
await p.subscribe("foo")
Expand All @@ -660,7 +656,6 @@ async def test_send_pubsub_ping(self, r: valkey.Valkey):
)
await p.aclose()

@skip_if_server_version_lt("3.0.0")
async def test_send_pubsub_ping_message(self, r: valkey.Valkey):
p = r.pubsub(ignore_subscribe_messages=True)
await p.subscribe("foo")
Expand All @@ -673,7 +668,6 @@ async def test_send_pubsub_ping_message(self, r: valkey.Valkey):

@pytest.mark.onlynoncluster
class TestPubSubConnectionKilled:
@skip_if_server_version_lt("3.0.0")
async def test_connection_error_raised_when_connection_dies(
self, r: valkey.Valkey, pubsub
):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_asyncio/test_scripting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import pytest_asyncio
from tests.conftest import skip_if_server_version_lt
from valkey import exceptions

multiply_script = """
Expand Down Expand Up @@ -36,7 +35,6 @@ async def test_eval(self, r):
assert await r.eval(multiply_script, 1, "a", 3) == 6

@pytest.mark.asyncio(forbid_global_loop=True)
@skip_if_server_version_lt("6.2.0")
async def test_script_flush(self, r):
await r.set("a", 2)
await r.script_load(multiply_script)
Expand Down
Loading

0 comments on commit 561edfb

Please sign in to comment.