Skip to content

Commit

Permalink
test: remove obsolete tests
Browse files Browse the repository at this point in the history
`skip_if_server_version_gte` doesn't currently make sense as there's
only one version of Valkey. All the tests that used that decorator
refered to older versions that are not available. We'll keep the
decorator itself for the future.

Signed-off-by: Mikhail Koviazin <mikhail.koviazin@aiven.io>
  • Loading branch information
mkmkme committed May 28, 2024
1 parent c175433 commit b0fa7da
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 105 deletions.
38 changes: 0 additions & 38 deletions tests/test_asyncio/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from tests.conftest import (
assert_resp_response,
is_resp2_connection,
skip_if_server_version_gte,
skip_unless_arch_bits,
)
from valkey._parsers import AsyncCommandsParser
Expand Down Expand Up @@ -2729,43 +2728,6 @@ async def test_asking_error(self, r: ValkeyCluster) -> None:
assert ask_node._free.pop().read_response.await_count
assert res == ["MOCK_OK"]

@skip_if_server_version_gte("7.0.0")
async def test_moved_redirection_on_slave_with_default(
self, r: ValkeyCluster
) -> None:
"""Test MovedError handling."""
key = "foo"
await r.set("foo", "bar")
# set read_from_replicas to True
r.read_from_replicas = True
primary = r.get_node_from_key(key, False)
moved_error = f"{r.keyslot(key)} {primary.host}:{primary.port}"

parse_response_orig = primary.parse_response
with mock.patch.object(
ClusterNode, "parse_response", autospec=True
) as parse_response_mock:

async def parse_response(
self, connection: Connection, command: str, **kwargs: Any
) -> Any:
if (
command == "GET"
and self.host != primary.host
and self.port != primary.port
):
raise MovedError(moved_error)

return await parse_response_orig(connection, command, **kwargs)

parse_response_mock.side_effect = parse_response

async with r.pipeline() as readwrite_pipe:
assert r.reinitialize_counter == 0
readwrite_pipe.get(key).get(key)
assert r.reinitialize_counter == 0
assert await readwrite_pipe.execute() == [b"bar", b"bar"]

async def test_readonly_pipeline_from_readonly_client(
self, r: ValkeyCluster
) -> None:
Expand Down
10 changes: 0 additions & 10 deletions tests/test_asyncio/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
assert_resp_response,
assert_resp_response_in,
is_resp2_connection,
skip_if_server_version_gte,
skip_if_server_version_lt,
skip_unless_arch_bits,
)
Expand Down Expand Up @@ -2279,11 +2278,6 @@ async def test_cluster_slaves(self, mock_cluster_resp_slaves):
await mock_cluster_resp_slaves.cluster("slaves", "nodeid"), dict
)

@skip_if_server_version_gte("7.0.0")
@pytest.mark.onlynoncluster
async def test_readwrite(self, r: valkey.Valkey):
assert await r.readwrite()

@pytest.mark.onlynoncluster
async def test_readonly_invalid_cluster_state(self, r: valkey.Valkey):
with pytest.raises(exceptions.ValkeyError):
Expand Down Expand Up @@ -2377,10 +2371,6 @@ async def test_geopos(self, r: valkey.Valkey):
async def test_geopos_no_value(self, r: valkey.Valkey):
assert await r.geopos("barcelona", "place1", "place2") == [None, None]

@skip_if_server_version_gte("4.0.0")
async def test_old_geopos_no_value(self, r: valkey.Valkey):
assert await r.geopos("barcelona", "place1", "place2") == []

async def test_georadius(self, r: valkey.Valkey):
values = (2.1909389952632, 41.433791470673, "place1") + (
2.1873744593677,
Expand Down
57 changes: 0 additions & 57 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
assert_resp_response,
assert_resp_response_in,
is_resp2_connection,
skip_if_server_version_gte,
skip_if_server_version_lt,
skip_unless_arch_bits,
)
Expand Down Expand Up @@ -1594,53 +1593,6 @@ def test_setrange(self, r):
assert r.setrange("a", 6, "12345") == 11
assert r["a"] == b"abcdef12345"

@skip_if_server_version_gte("7.0.0")
def test_stralgo_lcs(self, r):
key1 = "{foo}key1"
key2 = "{foo}key2"
value1 = "ohmytext"
value2 = "mynewtext"
res = "mytext"

# test LCS of strings
assert r.stralgo("LCS", value1, value2) == res
# test using keys
r.mset({key1: value1, key2: value2})
assert r.stralgo("LCS", key1, key2, specific_argument="keys") == res
# test other labels
assert r.stralgo("LCS", value1, value2, len=True) == len(res)
assert_resp_response(
r,
r.stralgo("LCS", value1, value2, idx=True),
{"len": len(res), "matches": [[(4, 7), (5, 8)], [(2, 3), (0, 1)]]},
{"len": len(res), "matches": [[[4, 7], [5, 8]], [[2, 3], [0, 1]]]},
)
assert_resp_response(
r,
r.stralgo("LCS", value1, value2, idx=True, withmatchlen=True),
{"len": len(res), "matches": [[4, (4, 7), (5, 8)], [2, (2, 3), (0, 1)]]},
{"len": len(res), "matches": [[[4, 7], [5, 8], 4], [[2, 3], [0, 1], 2]]},
)
assert_resp_response(
r,
r.stralgo(
"LCS", value1, value2, idx=True, withmatchlen=True, minmatchlen=4
),
{"len": len(res), "matches": [[4, (4, 7), (5, 8)]]},
{"len": len(res), "matches": [[[4, 7], [5, 8], 4]]},
)

@skip_if_server_version_gte("7.0.0")
def test_stralgo_negative(self, r):
with pytest.raises(exceptions.DataError):
r.stralgo("ISSUB", "value1", "value2")
with pytest.raises(exceptions.DataError):
r.stralgo("LCS", "value1", "value2", len=True, idx=True)
with pytest.raises(exceptions.DataError):
r.stralgo("LCS", "value1", "value2", specific_argument="INT")
with pytest.raises(ValueError):
r.stralgo("LCS", "value1", "value2", idx=True, minmatchlen="one")

def test_strlen(self, r):
r["a"] = "foo"
assert r.strlen("a") == 3
Expand Down Expand Up @@ -3249,11 +3201,6 @@ def test_cluster_setslot(self, mock_cluster_resp_ok):
def test_cluster_slaves(self, mock_cluster_resp_slaves):
assert isinstance(mock_cluster_resp_slaves.cluster("slaves", "nodeid"), dict)

@pytest.mark.onlynoncluster
@skip_if_server_version_gte("7.0.0")
def test_readwrite(self, r):
assert r.readwrite()

@pytest.mark.onlynoncluster
def test_readonly_invalid_cluster_state(self, r):
with pytest.raises(exceptions.ValkeyError):
Expand Down Expand Up @@ -3380,10 +3327,6 @@ def test_geopos(self, r):
def test_geopos_no_value(self, r):
assert r.geopos("barcelona", "place1", "place2") == [None, None]

@skip_if_server_version_gte("4.0.0")
def test_old_geopos_no_value(self, r):
assert r.geopos("barcelona", "place1", "place2") == []

def test_geosearch(self, r):
values = (
(2.1909389952632, 41.433791470673, "place1")
Expand Down

0 comments on commit b0fa7da

Please sign in to comment.