aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py (unfollow)
Commit message (Collapse)AuthorLines
2020-09-21Fix mod utils tests patch locationsGravatar ks129-4/+4
2020-09-21Accommodate new upload behaviour in testsGravatar Numerlor-2/+2
2020-09-21Upload output with codeblock escapes to pastebinGravatar Numerlor-0/+1
The output can't be sent to discord, but it won't affect anything in the paste service and can safely be uploaded to it.
2020-09-21Fix import order of mod utils testsGravatar ks129-1/+1
2020-09-21Fix import path of mod utilsGravatar ks129-1/+1
2020-09-21Fix end of file of mod utils testsGravatar ks129-1/+1
2020-09-20Apply recent changes of notify infraction to testGravatar ks129-3/+2
2020-09-20Try to fix location from where post infraction test get IDGravatar ks129-2/+2
2020-09-20Remove useless textwrap importGravatar ks129-1/+0
2020-09-20Remove special shortening from reasonGravatar ks129-1/+1
2020-09-20Lower duckpond threshold to increase activityGravatar Sebastiaan Zeeff-1/+1
There's not a lot of activity in our duckpond at the moment. To activate our duckies, I've decreased the duckpond threshold to 4. This means that a message will now be relayed once it's been ducked four times. Let's get all of our ducks in a row. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Add command to relay a message to duckpondGravatar Sebastiaan Zeeff-1/+11
This commit adds a command that allows admins to manually relay a message to the duckpond, regardless of duck counts and the checks done in the reaction event handler. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Use helper for duckpond's locked relay featureGravatar Sebastiaan Zeeff-15/+20
I've created a helper for duckpond's relay feature to allow me to use it separately from the command we're planning to add to the Cog. I opted not to include the lock in the original relay method to separate the logic more clearly. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Remove unit tests for duck pondGravatar Sebastiaan Zeeff-548/+0
I've removed the unit tests for duckpond in concordance with the new policy for writing unit tests for the bot The tests were unnecessarily complicated, difficult to maintain, and slowed development. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Fix relay race condition in duckpond using a lockGravatar Sebastiaan Zeeff-7/+17
Our duckpond suffered from a race condition: If multiple raw reaction events were received in quick succession and a message had enough ducks to take it over the duckpond threshold, the message would be relayed multiple times. The reason this happened is because the green checkmark emoji that stops a message from being relayed multiple times is only added after the message has been relayed. This means that multiple event triggers can make it past the green checkmark check before any of them has a chance to add a green checkmark. The solution was to create a relay lock that needs to be acquired before checking for the presence of a green checkmark and is only released after adding a green checkmark. This prevents multiple events from making it past the sentinel check. As our Cogs are potentially initialized before the event loop is created, the lock is load lazily when needed. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Add channel blacklist for duckpondGravatar Sebastiaan Zeeff-4/+38
As announcements already get a lot of exposure and have a high risk of getting "ducked", duckpond will now ignore those channels and never relay those announcements to our duckpond. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Ignore non-staff messages for our duckpondGravatar Sebastiaan Zeeff-1/+5
Some of our members have expressed concern that their messages would be "ducked" by staff members and relayed to the staff-only duckpond. Since duckpond is supposed to be a funny, staff-only affair, I've made duckpond ignore messages from non-staff members. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-20Determine eligible duckpond emojis dynamicallyGravatar Sebastiaan Zeeff-70/+27
Instead of maintaining a list of duckpond IDs manually, it's a much better idea to detect ducky emojis dynamically using the new emoji name grouping we've introduced: All emojis that start with `ducky_` will now be counted as a duckpond ducky. The unicode duck emoji obviously still counts in addition to custom emojis with the `ducky_` prefix. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-19Use global namespace `bot` for our RedisSessionGravatar Sebastiaan Zeeff-0/+1
As we're now planning on using Redis in multiple applications, it's important to minimize the risk of namespace collisions between different applications. The `async-rediscache` packages allows us to set a global namespace on an application level. I've chosen "bot" as the namespace for this application, which means all individual namespaces will automatically be prefixed by `bot.` whenever they are accessed. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-19Remove vestigial RedisCache class definitionGravatar Sebastiaan Zeeff-681/+1
As we're now using the `async-rediscache` package, it's no longer necessary to keep the `RedisCache` defined in `bot.utils.redis_cache` around. I've removed the file containing it and the tests written for it. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-09-19Use async-rediscache package for our redis cachesGravatar Sebastiaan Zeeff-163/+167
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]>
2020-09-16remove random space in `upvotes` valueGravatar Senjan21-1/+1
2020-09-16update the reddit emojis to actual emojis'Gravatar Senjan21-3/+3
2020-09-16Updating names of reddit emotes.Gravatar Senjan21-3/+4
2020-09-13Shorten infraction text when any other field than reason is too longGravatar ks129-0/+4
2020-09-11Verification: update & improve docstringsGravatar kwzrd-12/+11
After moving constants to config, the docstring references were not updated accordingly, and remained uppercase. This commit also removed the redundant list indentation.
2020-09-10Verification: move constants to configGravatar kwzrd-25/+43
2020-09-08Fix cog_check testsGravatar MarkKoz-8/+12
2020-09-08Fix tests for has_any_role_checkGravatar MarkKoz-16/+18
2020-09-08Rename role checks and decoratorsGravatar MarkKoz-33/+33
Make their names more in line with `has_any_role` for consistency.
2020-09-08Add everyone_ping filter.Gravatar kosayoda-11/+47
2020-09-07Implement role checks using has_any_roleGravatar MarkKoz-34/+35
Use `has_any_role` to reduce redundancy. Because discord.py always makes a check's predicate a coroutine, the checks now have to be awaited.
2020-09-07Remove everyone_ping rule from antispam.Gravatar kosayoda-152/+0
The feature will be moved to the filtering cog.
2020-09-06Use has_any_role's predicate directlyGravatar MarkKoz-31/+24
In some places, it's more appropriate than using with_role_check since it will raise CheckFailures. This applies to `cog_check`s and other things which effectively act as command checks.
2020-09-06Implement the without_role decorator by negating has_any_roleGravatar MarkKoz-6/+17
2020-09-05Remove with_role decorator in favour of has_any_roleGravatar MarkKoz-76/+58
`with_role` is obsolete because discord.py provides `has_any_role`.
2020-09-05Disable everyone_ping filter in AntiSpam cogGravatar Sebastiaan Zeeff-4/+8
As there are a few bugs in the implementation, I've temporarily disabled the at-everyone ping filter in the AntiSpam cog. We can disable it after we've fixed the bugs. Signed-off-by: Sebastiaan Zeeff <[email protected]>