Skip to content
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

Revert #8 and replace "redis" and "old valkey" with "server" #15

Merged
merged 5 commits into from
Jun 12, 2024
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
83 changes: 83 additions & 0 deletions tests/test_asyncio/test_cluster.py

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

import pytest
import valkey
from tests.conftest import skip_if_server_version_lt
from valkey._parsers import (
_AsyncHiredisParser,
_AsyncRESP2Parser,
Expand Down Expand Up @@ -89,6 +90,7 @@ 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: 11 additions & 5 deletions tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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 @@ -317,11 +318,13 @@ 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 @@ -347,6 +350,7 @@ 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 @@ -473,11 +477,13 @@ 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 @@ -581,6 +587,7 @@ 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 @@ -592,6 +599,7 @@ 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 @@ -608,6 +616,7 @@ 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 @@ -622,6 +631,7 @@ 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 @@ -666,11 +676,7 @@ async def test_connect_no_auth_supplied_when_required(self, r):
"""
with pytest.raises(valkey.AuthenticationError):
await r.execute_command(
"DEBUG",
"ERROR",
"ERR AUTH <password> called without any password "
"configured for the default user. Are you sure "
"your configuration is correct?",
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
)

async def test_connect_invalid_password_supplied(self, r):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_asyncio/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 @@ -392,6 +393,7 @@ 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: 7 additions & 1 deletion 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
from tests.conftest import get_protocol_version, skip_if_server_version_lt
from valkey.exceptions import ConnectionError
from valkey.typing import EncodableT
from valkey.utils import HIREDIS_AVAILABLE
Expand Down Expand Up @@ -608,6 +608,7 @@ 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 @@ -617,6 +618,7 @@ 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 @@ -636,6 +638,7 @@ 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 @@ -647,6 +650,7 @@ 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 @@ -656,6 +660,7 @@ 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 @@ -668,6 +673,7 @@ 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: 2 additions & 0 deletions tests/test_asyncio/test_scripting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import pytest_asyncio
from tests.conftest import skip_if_server_version_lt
from valkey import exceptions

multiply_script = """
Expand Down Expand Up @@ -35,6 +36,7 @@ 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
Loading