diff options
| author | 2020-05-24 19:09:45 +0200 | |
|---|---|---|
| committer | 2020-05-24 19:09:45 +0200 | |
| commit | ad8b1fa455e141074daec5047682e82ed96db1f5 (patch) | |
| tree | b00f5eb6096e96267886635077a23ee9e49bcc9e /tests | |
| parent | Add an option to use fakeredis in Bot. (diff) | |
Improve error and error testing for increment
Changed a RuntimeError to a KeyError (thanks @MarkKoz), and also added
some tests to ensure that the right errors are raised whenever this
method is used incorrectly.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bot/utils/test_redis_cache.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/bot/utils/test_redis_cache.py b/tests/bot/utils/test_redis_cache.py index dbbaef018..7405487ed 100644 --- a/tests/bot/utils/test_redis_cache.py +++ b/tests/bot/utils/test_redis_cache.py @@ -207,3 +207,11 @@ class RedisCacheTests(unittest.IsolatedAsyncioTestCase): # This should convert the type into a float. await self.redis.decrement("entropic", -2.5) self.assertEqual(await self.redis.get("entropic"), 7.5) + + # Let's test that they raise the right errors + with self.assertRaises(KeyError): + await self.redis.increment("doesn't_exist!") + + await self.redis.set("stringthing", "stringthing") + with self.assertRaises(TypeError): + await self.redis.increment("stringthing") |