test: remove redundant tests (#3642)

* test: remove redundant tests

* remove more tests

* add test_bitmap_commands

* add test_bitmap_commands and test_geo_commands to ignore list
This commit is contained in:
Daniel M 2024-09-04 14:55:35 -06:00 committed by GitHub
parent 65f96e3bb5
commit eef5be1729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 190 deletions

View File

@ -73,8 +73,11 @@ jobs:
- name: Run tests
working-directory: tests/fakeredis
run: |
poetry run pytest test/ --ignore test/test_hypothesis.py --ignore test/test_json/ \
--ignore test_bitmap_commands.py \
poetry run pytest test/ \
--ignore test/test_hypothesis.py \
--ignore test/test_geo_commands.py \
--ignore test/test_bitmap_commands.py \
--ignore test/test_json/ \
--junit-xml=results-tests.xml --html=report-tests.html -v
continue-on-error: true # For now to mark the flow as successful

View File

@ -1,147 +0,0 @@
import pytest
from fakeredis._command_args_parsing import extract_args
from fakeredis._helpers import SimpleError
def test_extract_args():
args = (
b"nx",
b"ex",
b"324",
b"xx",
)
(xx, nx, ex, keepttl), _ = extract_args(args, ("nx", "xx", "+ex", "keepttl"))
assert xx
assert nx
assert ex == 324
assert not keepttl
def test_extract_args__should_raise_error():
args = (b"nx", b"ex", b"324", b"xx", b"something")
with pytest.raises(SimpleError):
_, _ = extract_args(args, ("nx", "xx", "+ex", "keepttl"))
def test_extract_args__should_return_something():
args = (b"nx", b"ex", b"324", b"xx", b"something")
(xx, nx, ex, keepttl), left = extract_args(
args, ("nx", "xx", "+ex", "keepttl"), error_on_unexpected=False
)
assert xx
assert nx
assert ex == 324
assert not keepttl
assert left == (b"something",)
args = (
b"nx",
b"something",
b"ex",
b"324",
b"xx",
)
(xx, nx, ex, keepttl), left = extract_args(
args,
("nx", "xx", "+ex", "keepttl"),
error_on_unexpected=False,
left_from_first_unexpected=False,
)
assert xx
assert nx
assert ex == 324
assert not keepttl
assert left == [
b"something",
]
def test_extract_args__multiple_numbers():
args = (
b"nx",
b"limit",
b"324",
b"123",
b"xx",
)
(xx, nx, limit, keepttl), _ = extract_args(args, ("nx", "xx", "++limit", "keepttl"))
assert xx
assert nx
assert limit == [324, 123]
assert not keepttl
(xx, nx, limit, keepttl), _ = extract_args(
(
b"nx",
b"xx",
),
("nx", "xx", "++limit", "keepttl"),
)
assert xx
assert nx
assert not keepttl
assert limit == [None, None]
def test_extract_args__extract_non_numbers():
args = (
b"by",
b"dd",
b"nx",
b"limit",
b"324",
b"123",
b"xx",
)
(xx, nx, limit, sortby), _ = extract_args(args, ("nx", "xx", "++limit", "*by"))
assert xx
assert nx
assert limit == [324, 123]
assert sortby == b"dd"
def test_extract_args__extract_maxlen():
args = (b"MAXLEN", b"5")
(nomkstream, limit, maxlen, maxid), left_args = extract_args(
args, ("nomkstream", "+limit", "~+maxlen", "~maxid"), error_on_unexpected=False
)
assert not nomkstream
assert limit is None
assert maxlen == 5
assert maxid is None
args = (b"MAXLEN", b"~", b"5", b"maxid", b"~", b"1")
(nomkstream, limit, maxlen, maxid), left_args = extract_args(
args, ("nomkstream", "+limit", "~+maxlen", "~maxid"), error_on_unexpected=False
)
assert not nomkstream
assert limit is None
assert maxlen == 5
assert maxid == b"1"
args = (
b"by",
b"dd",
b"nx",
b"maxlen",
b"~",
b"10",
b"limit",
b"324",
b"123",
b"xx",
)
(nx, maxlen, xx, limit, sortby), _ = extract_args(
args, ("nx", "~+maxlen", "xx", "++limit", "*by")
)
assert xx
assert nx
assert maxlen == 10
assert limit == [324, 123]
assert sortby == b"dd"

View File

@ -1,16 +0,0 @@
import pytest
import redis
from test.testtools import raw_command
def test_asyncioio_is_used():
"""Redis 4.2+ has support for asyncio and should be preferred over aioredis"""
from fakeredis import aioredis
assert not hasattr(aioredis, "__version__")
def test_unknown_command(r: redis.Redis):
with pytest.raises(redis.ResponseError):
raw_command(r, "0 3 3")

View File

@ -1,16 +0,0 @@
from unittest.mock import patch
import redis
from fakeredis import FakeRedis
def test_mock():
# Mock Redis connection
def bar(redis_host: str, redis_port: int):
redis.Redis(redis_host, redis_port)
with patch("redis.Redis", FakeRedis):
# Call function
bar("localhost", 6000)
# Related to #36 - this should fail if mocking Redis does not work

View File

@ -8,9 +8,6 @@ from typing import Tuple, List, Optional
import pytest
import redis
import redis.client
from packaging.version import Version
REDIS_VERSION = Version(redis.__version__)
def round_str(x):
@ -18,10 +15,6 @@ def round_str(x):
return round(float(x))
def zincrby(r, key, amount, value):
return r.zincrby(key, amount, value)
def test_zpopmin(r: redis.Redis):
r.zadd("foo", {"one": 1})
r.zadd("foo", {"two": 2})
@ -215,14 +208,14 @@ def test_zcount_wrong_type(r: redis.Redis):
def test_zincrby(r: redis.Redis):
r.zadd("foo", {"one": 1})
assert zincrby(r, "foo", 10, "one") == 11
assert r.zincrby("foo", 10, "one") == 11
assert r.zrange("foo", 0, -1, withscores=True) == [(b"one", 11)]
def test_zincrby_wrong_type(r: redis.Redis):
r.sadd("foo", "bar")
with pytest.raises(redis.ResponseError):
zincrby(r, "foo", 10, "one")
r.zincrby("foo", 10, "one")
def test_zrange_descending(r: redis.Redis):