aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-09-19 21:45:54 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2020-09-19 22:14:37 +0200
commitfc058490d62fa373e6ebb01392c511027401e72f (patch)
tree1125c6429de34a09082d88703ba12f2d68b120cc /tests/helpers.py
parentMerge pull request #1158 from python-discord/config-update (diff)
Use async-rediscache package for our redis caches
I've migrated our redis caches over to the async-rediscache package that we've recently released (https://git.pydis.com/async-rediscache). The main functionality remains the same, although the package handles some things, like getting the active session, differently internally. The main changes you'll note for our bot are: - We create a RedisSession instance and ensure that it connects before we even create a Bot instance in `__main__.py`. - We are now actually using a connection pool instead of a single connection. - Our Bot subclass now has a new required kwarg: `redis_session`. - Bool values are now properly converted to and from typestrings. In addition, I've made sure that our MockBot passes a MagicMock for the new `redis_session` kwarg when creating a Bot instance for the spec_set. Signed-off-by: Sebastiaan Zeeff <[email protected]>
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index facc4e1af..e47fdf28f 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -308,7 +308,11 @@ class MockBot(CustomMockMixin, unittest.mock.MagicMock):
Instances of this class will follow the specifications of `discord.ext.commands.Bot` instances.
For more information, see the `MockGuild` docstring.
"""
- spec_set = Bot(command_prefix=unittest.mock.MagicMock(), loop=_get_mock_loop())
+ spec_set = Bot(
+ command_prefix=unittest.mock.MagicMock(),
+ loop=_get_mock_loop(),
+ redis_session=unittest.mock.MagicMock(),
+ )
additional_spec_asyncs = ("wait_for", "redis_ready")
def __init__(self, **kwargs) -> None: