aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-23 10:27:32 -0700
committerGravatar MarkKoz <[email protected]>2020-05-23 10:27:32 -0700
commita52a13020f3468c671cb549052a9c8e303ae9d8c (patch)
treeef371c080a7afebd7aa947d736cc9ad2f3204927
parentDRY approach to typestring prefix resolution (diff)
Remove redis session mock from MockBot
It's not feasible to mock it because all the commands return futures rather than being coroutines, so they cannot automatically be turned into AsyncMocks. Furthermore, no code should ever use the redis session directly besides RedisCache. Since the tests for RedisCache already use fakeredis, there's no use in trying to mock redis in MockBot.
-rw-r--r--tests/helpers.py16
1 files changed, 0 insertions, 16 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 2b176db79..5ad826156 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -7,7 +7,6 @@ import unittest.mock
from asyncio import AbstractEventLoop
from typing import Iterable, Optional
-import aioredis.abc
import discord
from aiohttp import ClientSession
from discord.ext.commands import Context
@@ -268,17 +267,6 @@ class MockAPIClient(CustomMockMixin, unittest.mock.MagicMock):
spec_set = APIClient
-class MockRedisPool(CustomMockMixin, unittest.mock.MagicMock):
- """
- A MagicMock subclass to mock an aioredis connection pool.
-
- Instances of this class will follow the specifications of `aioredis.abc.AbcPool` instances.
- For more information, see the `MockGuild` docstring.
- """
- spec_set = aioredis.abc.AbcPool
- additional_spec_asyncs = ("execute", "execute_pubsub")
-
-
def _get_mock_loop() -> unittest.mock.Mock:
"""Return a mocked asyncio.AbstractEventLoop."""
loop = unittest.mock.create_autospec(spec=AbstractEventLoop, spec_set=True)
@@ -309,10 +297,6 @@ class MockBot(CustomMockMixin, unittest.mock.MagicMock):
self.http_session = unittest.mock.create_autospec(spec=ClientSession, spec_set=True)
self.stats = unittest.mock.create_autospec(spec=AsyncStatsClient, spec_set=True)
- # fakeredis can't be used cause it'd require awaiting a coroutine to create the pool,
- # which cannot be done here in __init__.
- self.redis_session = MockRedisPool()
-
# Create a TextChannel instance to get a realistic MagicMock of `discord.TextChannel`
channel_data = {