Skip to content

Commit

Permalink
test: Fix some more untyped tests (#4373)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnagara authored Jun 20, 2023
1 parent 4a3c547 commit d8b2360
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ api-tests:
SNUBA_SETTINGS=test pytest -vv tests/*_api.py

backend-typing:
mypy snuba tests scripts --strict --config-file mypy.ini --exclude 'tests/datasets|tests/query|tests/state|tests/snapshots|tests/clickhouse|tests/test_split.py'
mypy snuba tests scripts --strict --config-file mypy.ini --exclude 'tests/datasets|tests/query|tests/snapshots|tests/clickhouse|tests/test_split.py'

install-python-dependencies:
pip uninstall -qqy uwsgi # pip doesn't do well with swapping drop-ins
Expand Down
13 changes: 8 additions & 5 deletions tests/state/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from snuba.state.cache.abstract import Cache, ExecutionError, ExecutionTimeoutError
from snuba.state.cache.redis.backend import RedisCache
from snuba.utils.codecs import ExceptionAwareCodec
from snuba.utils.serializable_exception import SerializableException
from snuba.utils.serializable_exception import (
SerializableException,
SerializableExceptionDict,
)
from tests.assertions import assert_changes, assert_does_not_change

redis_client = get_redis_client(RedisClientKey.CACHE)
Expand Down Expand Up @@ -44,7 +47,7 @@ def encode(self, value: bytes) -> bytes:

def decode(self, value: bytes) -> bytes:
try:
ret = rapidjson.loads(value)
ret: SerializableExceptionDict = rapidjson.loads(value)
if not isinstance(ret, dict):
return value
if ret.get("__type__", "NOP") == "SerializableException":
Expand All @@ -55,7 +58,7 @@ def decode(self, value: bytes) -> bytes:
return value

def encode_exception(self, value: SerializableException) -> bytes:
return rapidjson.dumps(value.to_dict()).encode("utf-8")
return bytes(rapidjson.dumps(value.to_dict()).encode("utf-8"))


@pytest.fixture
Expand Down Expand Up @@ -260,10 +263,10 @@ def test_notify_queue_ttl() -> None:
num_waiters = 9

class DelayedRedisClient:
def __init__(self, redis_client):
def __init__(self, redis_client: RedisClientType) -> None:
self._client = redis_client

def __getattr__(self, attr: str):
def __getattr__(self, attr: str) -> Any:
# simulate the queue pop taking longer than expected.
# the notification queue TTL is 60 seconds so running into a timeout
# shouldn't happen (unless something has drastically changed in the TTL
Expand Down
2 changes: 1 addition & 1 deletion tests/state/test_record.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from snuba.state import _kafka_producer


def test_get_producer():
def test_get_producer() -> None:
assert _kafka_producer() is not None

0 comments on commit d8b2360

Please sign in to comment.