aboutsummaryrefslogtreecommitdiffstats
path: root/tests (follow)
Commit message (Collapse)AuthorAgeLines
...
| | | | * | | | | | Make .items return ItemsView instead of AsyncIterGravatar Leon Sandøy2020-05-24-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There really was no compelling reason why this method should return an AsyncIterator or than that `async for items in cache.items()` has nice readability, but there were a few concerns. One is a concern about race conditions raised by @SebastiaanZ, and @MarkKoz raised a concern that it was misleading to have an AsyncIterator that only "pretended" to be lazy. To address these concerns, I've refactored it to return a regular ItemsView instead. I also improved the docstring, and fixed the relevant tests.
| | | | * | | | | | Remove redis session mock from MockBotGravatar MarkKoz2020-05-23-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | | DRY approach to typestring prefix resolutionGravatar Leon Sandøy2020-05-23-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thanks to @kwzrd for this idea, basically we're making a constant with the typestring prefixes and iterating that in all our converters. These converter functions will also now raise TypeErrors if we try to convert something that isn't in this constants list. I've also added a new test that tests this functionality.
| | | | * | | | | | Fix typo in test_to_dict docstringGravatar Leon Sandøy2020-05-23-1/+1
| | | | | | | | | |
| | | | * | | | | | Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-23-4/+7
| | | | |\| | | | |
| | | | * | | | | | Complete asyncified test suite for RedisCacheGravatar Leon Sandøy2020-05-23-94/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit just alters existing code to work with the new interface, and with async. All tests are passing successfully.
| | | | * | | | | | Finish .set and .get, and add tests.Gravatar Leon Sandøy2020-05-23-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The .set and .get will accept ints, floats, and strings. These will be converted into "typestrings", which is basically just a simple format that's been invented for this object. For example, an int looks like `b"i|2423"`. Note how it is still stored as a bytestring (like everything in Redis), but because of this prefix we are able to coerce it into the type we want on the way out of the db.
| | | | * | | | | | Use autospecced mocks in MockBot for the stats and aiohttp sessionGravatar MarkKoz2020-05-22-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | | Properly mock the redis pool in MockBotGravatar MarkKoz2020-05-22-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because some of the redis pool/connection methods return futures rather than being coroutines, the redis pool had to be mocked using the CustomMockMixin so it could take advantage of `additional_spec_asyncs` to use AsyncMocks for these future-returning methods.
| | | | * | | | | | Fix unawaited coro warning when instantiating Bot for MockBot's specGravatar MarkKoz2020-05-22-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix is to mock the loop and pass it to the Bot. It will then set it as `self.loop` rather than trying to get an event loop from asyncio. The `create_task` patch has been moved to this loop mock rather than being done in MockBot to ensure that it applies to anything calling it when instantiating the Bot.
| | | | * | | | | | Improve aiohttp context manager mocking in snekbox testsGravatar MarkKoz2020-05-22-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm not sure how it even managed to work before. It was calling the `post` coroutine (without specifying a URL) and then changing `__aenter__`. Now, a separate mock is created for the context manager and the `post` simply returns that mocked context manager.
| | | | * | | | | | Fix assertion for `create_task` in duck pond testsGravatar MarkKoz2020-05-22-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The assertion wasn't using the assertion method. Furthermore, it was testing a non-existent function `create_loop` rather than `create_task`.
| | | | * | | | | | Set up async testbedGravatar Leon Sandøy2020-05-22-189/+128
| | | | | | | | | |
| | | | * | | | | | Test suite for the redis dict.Gravatar Leon Sandøy2020-05-17-0/+189
| | | | | |_|/ / / | | | | |/| | | |
| | | * | | | | | AntiMalware tests - Switched from monkeypatch to unittest.patchGravatar Jannes Jonkers2020-05-25-2/+2
| | | | | | | | |
| | | * | | | | | AntiMalware Refactor - Moved embed descriptions into constants, added tests ↵Gravatar Jannes Jonkers2020-05-11-18/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for embed descriptions
| | | * | | | | | AntiMalware Tests - Removed exact log content checksGravatar Jannes Jonkers2020-05-11-19/+2
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - added a missing case for no extensions in ↵Gravatar Jannes Jonkers2020-05-11-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_get_disallowed_extensions
| | | * | | | | | AntiMalware Tests - extracted the method for determining disallowed ↵Gravatar Jannes Jonkers2020-05-11-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | extensions and added a test for it.
| | | * | | | | | AntiMalware Tests - implemented minor feedbackGravatar Jannes Jonkers2020-05-11-12/+12
| | | | | | | | |
| | | * | | | | | Update tests/bot/cogs/test_antimalware.pyGravatar MrGrote2020-05-08-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Co-authored-by: Mark <[email protected]>
| | | * | | | | | AntiMalware Tests - Switched to unittest.IsolatedAsyncioTestCaseGravatar Jannes Jonkers2020-05-07-29/+19
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for txt file attachmentGravatar Jannes Jonkers2020-05-07-2/+23
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for valid attachmentGravatar Jannes Jonkers2020-05-07-0/+9
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest message deletion logGravatar Jannes Jonkers2020-05-07-4/+28
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for cog setupGravatar Jannes Jonkers2020-05-07-0/+10
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for messages that were deleted in the ↵Gravatar Jannes Jonkers2020-05-07-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | meantime.
| | | * | | | | | AntiMalware Tests - Added unittest for the embed for a python file.Gravatar Jannes Jonkers2020-05-07-1/+24
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for messages send by staffGravatar Jannes Jonkers2020-05-07-1/+12
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittests for deletion of message and ignoring of dmsGravatar Jannes Jonkers2020-05-07-1/+21
| | | | | | | | |
| | | * | | | | | AntiMalware Tests - Added unittest for message without attachmentGravatar Jannes Jonkers2020-05-07-0/+20
| | | |/ / / / /
| | * | | | | | Infr. Tests: Add `apply_infraction` awaiting assertion with argsGravatar ks1292020-05-30-0/+6
| | | | | | | |
| | * | | | | | Simplify infraction reason truncation testsGravatar ks1292020-05-30-13/+7
| | | | | | | |
| | * | | | | | Infr Tests: Make `get_active_infraction` return `None`Gravatar ks1292020-05-20-1/+1
| | | | | | | |
| | * | | | | | Infr. Test: Replace `get_active_mock` return valueGravatar ks1292020-05-20-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Replace `{"foo": "bar"}` with `{"id": 1}`
| | * | | | | | Infr. Tests: Replace `str` with `dict`Gravatar ks1292020-05-20-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | To allow `.get`, I had to replace `str` return value with `dict`
| | * | | | | | Infr. Tests: Add more content to await commentGravatar ks1292020-05-20-2/+2
| | | | | | | |
| | * | | | | | ModLog Tests: Fix embed description truncate testGravatar ks1292020-05-20-1/+1
| | | | | | | |
| | * | | | | | Merge branch 'master' into ban-kick-reason-lengthGravatar ks1292020-05-20-11/+183
| | |\ \ \ \ \ \ | | | | |/ / / / | | | |/| | | |
| | * | | | | | Infraction Tests: Small fixesGravatar ks1292020-05-20-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove unnecessary space from placeholder - Rename `has_active_infraction` to `get_active_infraction`
| | * | | | | | ModLog Tests: Fix truncation tests docstringGravatar ks1292020-05-20-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Co-authored-by: Leon Sandøy <[email protected]>
| | * | | | | | (Infractions and ModLog Tests): Replaced `shortening` with `truncation`, ↵Gravatar ks1292020-04-16-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | removed unnecessary type hint and added comment to kick truncation test about awaiting `kick`.
| | * | | | | | (ModLog Tests): Created reason shortening tests for `send_log_message`.Gravatar ks1292020-04-16-0/+29
| | | | | | | |
| | * | | | | | (Infraction Tests): Created reason shortening tests for ban and kick.Gravatar ks1292020-04-16-0/+54
| | | | | | | |
| | * | | | | | (Test Helpers): Added `__ge__` function to `MockRole` for comparing.Gravatar ks1292020-04-15-0/+4
| | | |_|_|/ / | | |/| | | |
| * | | | | | Fix failing tests related to avatar_hashGravatar Leon Sandøy2020-05-27-5/+0
| | |/ / / / | |/| | | |
| * | | | | Merge branch 'master' into eval-timeout-increaseGravatar Dennis Pham2020-05-19-3/+2
| |\ \ \ \ \ | | | |_|_|/ | | |/| | |
| | * | | | Use `Command`-object for `send_help`Gravatar Sebastiaan Zeeff2020-05-17-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As @mathsman5133 pointed out, it's better to use the `Command`-instance we typically already have in the current context than to rely on parsing the qualified name again. The invocation is now done as: `await ctx.send_help(ctx.command)`
| | * | | | Use `send_help` to invoke command helpGravatar Sebastiaan Zeeff2020-05-17-2/+1
| | | |/ / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the refactoring of the help command, we need to use the built-in method of calling the help command: `Context.send_help`. As an argument, the qualified name (a string containing the full command path, including parents) of the command can be passed. Examples: - await ctx.send_help("reminders edit") This would send a help embed with information on `!reminders edit` to the Context. - await ctx.send_help(ctx.command.qualified_name) This would extract the qualified name of the command, which is the full command path, and send a help embed to Context. - await ctx.send_help() This will send the main "root" help embed to the Context.
| * / | | Change tests to use the new timeout constantGravatar Numerlor2020-05-15-1/+5
| |/ / /