aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-22 16:25:10 -0700
committerGravatar MarkKoz <[email protected]>2020-05-22 16:25:10 -0700
commitd8f1634ab68b2cd480d57c8b9da8834866b5c9cc (patch)
tree4802cc5d981c54ff9090b21aee5314bc448cd74e
parentProperly mock the redis pool in MockBot (diff)
Use autospecced mocks in MockBot for the stats and aiohttp session
This will help catch anything that tries to get/set an attribute/method which doesn't exist. It'll also catch missing/too many parameters being passed to methods.
-rw-r--r--tests/helpers.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 33d4f787c..d226be3f0 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -9,9 +9,11 @@ from typing import Iterable, Optional
import aioredis.abc
import discord
+from aiohttp import ClientSession
from discord.ext.commands import Context
from bot.api import APIClient
+from bot.async_stats import AsyncStatsClient
from bot.bot import Bot
@@ -304,6 +306,8 @@ class MockBot(CustomMockMixin, unittest.mock.MagicMock):
self.loop = _get_mock_loop()
self.api_client = MockAPIClient(loop=self.loop)
+ 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__.