aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py (follow)
Commit message (Collapse)AuthorAgeLines
* Lazily create `guild` on text/voice channel mocksGravatar wookie1842024-05-25-2/+12
| | | | In many cases the Guild mock is not needed so this makes tests faster
* Improve accuracy (and efficiency) of MockContextGravatar wookie1842024-04-02-8/+12
|
* Fix some test warnings (#2675)Gravatar wookie1842023-07-09-0/+10
| | | | | | | * Fix test warnings * Remove unnecessary event_loop parameters This is not necessary as the current event loop will be used which is the same as self.bot.loop. Removing these should slightly improve test speed as the mock for self.bot.loop doesn't need to be created.
* Update MockAttachment data with new expected fieldsGravatar Chris Lovering2023-06-21-1/+12
|
* Write custom get_role func for MockMemberGravatar Chris Lovering2023-06-21-0/+3
| | | | The new d.py Member.get_role uses the Guild.get_role function if the member has the role. SInce we don't set Guild.roles overwrite this instead.
* Improve test speed using some cached_property decorators on mocksGravatar wookie1842023-04-15-6/+30
|
* Migrate code style to ruffGravatar Chris Lovering2023-04-11-94/+93
| | | | | Co-authored-by: Boris Muratov <[email protected]> Co-authored-by: wookie184 <[email protected]>
* Merge branch 'main' into new-filtersGravatar mbaruh2023-02-28-3/+32
|\
| * add the `flags` key to the member_data dictionaryGravatar shtlrs2023-02-28-1/+1
| | | | | | | | | | The value 2 represents the `COMPLETED_ONBOARDING` flag, found here https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-flags
| * Implement all reviewsGravatar Ibrahim2023-02-23-1/+10
| | | | | | | | | | | | | | | | + Remove commented code + Remove unecessarily syncting the bot + Handle direct tag commads + 3.10 type hinting in concerned functions + Add `MockInteractionMessage` + Fix tests for `try_get_tag`
| * Update tests for `/tag` as of migration to slash commandsGravatar Ibrahim2750mi2023-02-14-0/+20
| |
| * Update botcore module nameGravatar Chris Lovering2022-11-26-2/+2
| |
* | Fix testsGravatar mbaruh2022-10-01-3/+3
| |
* | Merge branch 'main' into new-filtersGravatar mbaruh2022-09-24-1/+23
|\|
| * Removed "redis_ready" from additional_spec_asyncs in MockBot (#2275)Gravatar Aleksey Zasorin2022-09-16-1/+1
| | | | | | The attribute was removed from Bot in fc05849
| * fix: don't include replied mentions in mention filter (#2017)Gravatar arl2022-08-18-0/+22
| | | | | | | | | | Co-authored-by: Izan <[email protected]> Co-authored-by: TizzySaurus <[email protected]> Co-authored-by: Xithrius <[email protected]>
* | Accept strings in channel scope and change role string interpretationGravatar mbaruh2022-07-16-1/+1
|/ | | | | The channel scope settings were changed to accomodate strings. That means that if a string is specified, the bot will look whether the context channel's name matches. If it's a number, it will match the ID. Accordingly the same changed was applied to the bypass roles and pings settings: if it's a non-numeric string, it will look for a role with that name.
* Use new application format for message data in test helperGravatar Chris Lovering2022-06-28-1/+1
|
* Speed Up Sync Cog LoadingGravatar Hassan Abouelela2022-04-23-1/+1
| | | | | | | | | | | | The user syncer was blocking the startup of the sync cog due to having to perform thousands of pointless member fetch requests. This speeds up that process by increasing the probability that the cache is up-to-date using `Guild.chunked`, and limiting the fetches to members who were in the guild during the previous sync only. Co-authored-by: ChrisJL <[email protected]> Co-authored-by: wookie184 <[email protected]> Signed-off-by: Hassan Abouelela <[email protected]>
* Pass the now required intents kwarg when creating MockBotGravatar Chris Lovering2022-04-19-0/+1
|
* Update test helpers with breaking d.py changesGravatar Chris Lovering2022-04-18-0/+4
| | | | | | | region was removed from the guild object, so this has been replaced with features add_cog is now async, so it is now an async_mock during tests Two new required voice_channel attrs were added channel.type is required to be set to ChannelType due to a new isinstance check in d.py
* Adding missing kwargs required by BotBase in test helperGravatar Chris Lovering2022-04-18-0/+3
|
* Remove async stats and site api wrapperGravatar Chris Lovering2022-04-18-2/+2
| | | | We now source them from bot-core, so no need to have them here too.
* Revert "Update all references of discord.py to disnake"Gravatar Chris Lovering2022-03-15-62/+62
| | | | This reverts commit 960619c23300c56c8aaa454edc7241e2badf80ad.
* Update all references of discord.py to disnakeGravatar Chris Lovering2022-03-05-62/+62
| | | | All of the tag content is out of scope for this PR.
* Merge branch 'main' into discord-2.0Gravatar Matteo Bertucci2021-10-10-1/+6
|\
| * Merge branch 'main' into ignore-infra-mods-errorsGravatar Joe Banks2021-10-05-1/+4
| |\
| | * Use scheduling create_task util instead of creating from loop directlyGravatar Numerlor2021-09-11-1/+4
| | | | | | | | | | | | | | | The util attaches an error logging callback instead of relying on python's exception logging which only occurs when the task is destroyed
| * | Fix testsGravatar Izan2021-09-01-0/+2
| |/
* / Migrate to Discord.py 2.0a0Gravatar Matteo Bertucci2021-09-06-4/+23
|/ | | | | | | | Since the Discord.py repository has been archived, we can switch to the latest commit of 2.0a0, knowing no breaking change will occur (still pinned to the commit just in case). This commits fixes any problem related to the migration: - New avatar interface - TZ aware datetimes - Various inernal API changes
* Merge branch 'main' into voicechannel-muteGravatar Xithrius2021-07-08-0/+22
|\
| * chore: Update tests for the new codejam create commandGravatar ToxicKidz2021-07-05-0/+22
| |
* | Merge branch 'main' into voicechannel-muteGravatar Hassan Abouelela2021-05-04-0/+2
|\|
| * Merge branch 'master' into error-handler-testGravatar ks1292021-02-19-1/+1
| |\
| * \ Merge branch 'master' into error-handler-testGravatar ks1292020-11-21-19/+2
| |\ \
| * \ \ Merge remote-tracking branch 'upstream/master' into error-handler-testGravatar ks1292020-09-27-12/+46
| |\ \ \
| * | | | Test Helpers: Added new attribute to `MockContext`Gravatar ks1292020-05-18-0/+2
| | | | | | | | | | | | | | | | | | | | Added `invoked_from_error_handler` attribute that is `False` default.
* | | | | Merge branch 'master' into voicechannel-muteGravatar Hassan Abouelela2020-12-22-1/+1
|\ \ \ \ \ | | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Hassan Abouelela<[email protected]> # Conflicts # bot/exts/moderation/silence.py # bot/exts/moderation/test_silence.py
| * | | | Fix pending testsGravatar Joe Banks2020-12-19-1/+1
| | |_|/ | |/| |
* / | | General Silence Class TestsGravatar Hassan Abouelela2020-11-23-3/+22
|/ / / | | | | | | | | | | | | | | | Adds tests for helper functions in the silence cog. Signed-off-by: Hassan Abouelela <[email protected]>
* | | Merge master, fix conflicts, and create redis session in silence testsGravatar MarkKoz2020-10-09-1/+5
|\ \ \ | | |/ | |/|
| * | Use async-rediscache package for our redis cachesGravatar Sebastiaan Zeeff2020-09-19-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* | | Tests: optionally prevent autospec helper from passing mocksGravatar MarkKoz2020-08-17-19/+2
|/ / | | | | | | | | | | | | | | | | Not everything that's decorated needs the mocks that are patched. Being required to add the args to the test function anyway is annoying. It's especially bad if trying to decorate an entire test suite, as every test would need the args. Move the definition to a separate module to keep things cleaner.
* | Merge remote-tracking branch 'origin/master' into ↵Gravatar MarkKoz2020-06-02-11/+23
|\ \ | | | | | | | | | bug/filters/928/non-ascii-token
| * \ Merge branch 'master' into ban-kick-reason-lengthGravatar Mark2020-05-30-11/+19
| |\ \
| | * | MockBot needs to be aware of redis_readyGravatar Leon Sandøy2020-05-24-1/+1
| | | | | | | | | | | | | | | | | | | | Forgot to update the additional_spec_asyncs when changing the name of this Bot attribute to be public.
| | * | 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.
| | * | Finish .set and .get, and add tests.Gravatar Leon Sandøy2020-05-23-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.