Skip to content
Open
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
2 changes: 0 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ build
build==1.2.2.post1 ; platform_python_implementation == "PyPy"
click==8.0.4
invoke==2.2.0
mock
mock==5.1.0 ; platform_python_implementation == "PyPy"
packaging>=20.4
packaging==24.2 ; platform_python_implementation == "PyPy"

Expand Down
34 changes: 17 additions & 17 deletions tests/test_asyncio/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from asyncio import Lock as AsyncLock
from asyncio import sleep as async_sleep
from typing import Optional, Tuple, Union
from unittest.mock import AsyncMock, call

import pytest
import pytest_asyncio
import redis
from mock.mock import Mock, call
from redis import AuthenticationError, DataError, RedisError, ResponseError
from redis.asyncio import Connection, ConnectionPool, Redis
from redis.asyncio.retry import Retry
Expand Down Expand Up @@ -340,10 +340,10 @@ class TestStreamingCredentialProvider:
indirect=True,
)
async def test_async_re_auth_all_connections(self, credential_provider):
mock_connection = Mock(spec=Connection)
mock_connection = AsyncMock(spec=Connection)
mock_connection.retry = Retry(NoBackoff(), 0)
mock_another_connection = Mock(spec=Connection)
mock_pool = Mock(spec=ConnectionPool)
mock_another_connection = AsyncMock(spec=Connection)
mock_pool = AsyncMock(spec=ConnectionPool)
mock_pool.connection_kwargs = {
"credential_provider": credential_provider,
}
Expand Down Expand Up @@ -391,16 +391,16 @@ async def re_auth_callback(token):
indirect=True,
)
async def test_async_re_auth_partial_connections(self, credential_provider):
mock_connection = Mock(spec=Connection)
mock_connection = AsyncMock(spec=Connection)
mock_connection.retry = Retry(NoBackoff(), 3)
mock_another_connection = Mock(spec=Connection)
mock_another_connection = AsyncMock(spec=Connection)
mock_another_connection.retry = Retry(NoBackoff(), 3)
mock_failed_connection = Mock(spec=Connection)
mock_failed_connection = AsyncMock(spec=Connection)
mock_failed_connection.read_response.side_effect = ConnectionError(
"Failed auth"
)
mock_failed_connection.retry = Retry(NoBackoff(), 3)
mock_pool = Mock(spec=ConnectionPool)
mock_pool = AsyncMock(spec=ConnectionPool)
mock_pool.connection_kwargs = {
"credential_provider": credential_provider,
}
Expand Down Expand Up @@ -454,14 +454,14 @@ async def re_auth_callback(token):
indirect=True,
)
async def test_re_auth_pub_sub_in_resp3(self, credential_provider):
mock_pubsub_connection = Mock(spec=Connection)
mock_pubsub_connection = AsyncMock(spec=Connection)
mock_pubsub_connection.get_protocol.return_value = 3
mock_pubsub_connection.credential_provider = credential_provider
mock_pubsub_connection.retry = Retry(NoBackoff(), 3)
mock_another_connection = Mock(spec=Connection)
mock_another_connection = AsyncMock(spec=Connection)
mock_another_connection.retry = Retry(NoBackoff(), 3)

mock_pool = Mock(spec=ConnectionPool)
mock_pool = AsyncMock(spec=ConnectionPool)
mock_pool.connection_kwargs = {
"credential_provider": credential_provider,
}
Expand Down Expand Up @@ -516,14 +516,14 @@ async def re_auth_callback(token):
indirect=True,
)
async def test_do_not_re_auth_pub_sub_in_resp2(self, credential_provider):
mock_pubsub_connection = Mock(spec=Connection)
mock_pubsub_connection = AsyncMock(spec=Connection)
mock_pubsub_connection.get_protocol.return_value = 2
mock_pubsub_connection.credential_provider = credential_provider
mock_pubsub_connection.retry = Retry(NoBackoff(), 3)
mock_another_connection = Mock(spec=Connection)
mock_another_connection = AsyncMock(spec=Connection)
mock_another_connection.retry = Retry(NoBackoff(), 3)

mock_pool = Mock(spec=ConnectionPool)
mock_pool = AsyncMock(spec=ConnectionPool)
mock_pool.connection_kwargs = {
"credential_provider": credential_provider,
}
Expand Down Expand Up @@ -583,10 +583,10 @@ async def test_fails_on_token_renewal(self, credential_provider):
RequestTokenErr,
RequestTokenErr,
]
mock_connection = Mock(spec=Connection)
mock_connection = AsyncMock(spec=Connection)
mock_connection.retry = Retry(NoBackoff(), 0)
mock_another_connection = Mock(spec=Connection)
mock_pool = Mock(spec=ConnectionPool)
mock_another_connection = AsyncMock(spec=Connection)
mock_pool = AsyncMock(spec=ConnectionPool)
mock_pool.connection_kwargs = {
"credential_provider": credential_provider,
}
Expand Down
3 changes: 2 additions & 1 deletion tests/test_asyncio/test_multidb/test_healthcheck.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import AsyncMock, Mock

import pytest
from mock.mock import AsyncMock, Mock

from redis.asyncio.multidb.database import Database
from redis.asyncio.multidb.healthcheck import (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import threading
from time import sleep
from typing import Optional, Tuple, Union
from unittest.mock import Mock, call

import pytest
import redis
from mock.mock import Mock, call
from redis import AuthenticationError, DataError, Redis, ResponseError
from redis.auth.err import RequestTokenErr
from redis.backoff import NoBackoff
Expand Down
Loading