| Commit message (Collapse) | Author | Age | Lines |
| |
|
|
|
|
|
| |
* Rename to `_silence_overwrites`
* Reduce responsibilities to only setting permission overwrites
* Log in `silence` instead
* Add to notifier in `silence` instead
|
| | |
|
| | |
|
| |
|
| |
Co-authored-by: Numerlor <[email protected]>
|
| | |
|
| | |
|
| |
|
|
| |
It's not really necessary to set to True when mocking functions.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
They don't do anything because they patch the class rather than the
instance. It's too late for patching the instance to work since the
`setUp` fixture, which instantiates the cog, executes before the patches
do. Patching `setUp` would work (and its done in the other test cases),
but some tests in this case will need the unpatched function too.
Patching it doesn't serve much benefit to most tests anyway, so it's
not worth the effort trying to make them work where they aren't needed.
|
| |
|
|
|
|
| |
The module is imported anyway to keep imports short and clean. Using it
in patch targets is shorter and allows for the two imports from the
module to be removed.
|
| | |
|
| |
|
|
|
| |
Duplicating strings in assertions is redundant, closely coupled, and
less maintainable.
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
Use a False for `add_reactions` in the mock overwrite rather than None
to be sure the default (also None) is actually set for it.
Fix channels set by `_init_cog` not being mocked properly.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
An `AsyncMock` fails because it returns a coroutine which may only be
awaited once. However, an `asyncio.Future` is perfect because it is
easy to create and can be awaited repeatedly, just like the actual
`asyncio.Task` that is being mocked.
|
| |
|
|
| |
Reduce code redundancy by only defining them once.
|
| |
|
|
|
| |
Now that there are separate test cases, there's no need to keep the
fixtures separate.
|
| | |
|
| | |
|
| |
|
|
|
| |
Add a fixture to set up mocks for a successful `unsilence` call. This
reduces code redundancy.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
| |
Moderation notifications are no longer sent so that doesn't need to be
tested.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
| |
It's a more accurate name since it also reschedules unsilences now.
|
| |
|
|
|
|
| |
The event is redundant because the task can be awaited directly to block
until it's complete. If the task is already done, the await will
instantly finish.
|
| |
|
|
|
|
|
|
| |
`datetime.timestamp()` assumes naïve `datetime`s are in local time, so
getting POSIX timestamps in UTC isn't easy for naïve ones. Technically,
the timestamp's timezone doesn't matter if all code is on the same page
and parsing it with the same timezone. Keeping it in the local timezone
would be okay then, but I feel safer locking it to UTC explicitly.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Remove the moderator notification when unloading the cog because. Its
purpose was to remind to manually unsilence channels. However, this
purpose is now obsolete due to automatic rescheduling.
The notification was buggy anyway due to a race condition with the bot
shutting down, and that'd be further complicated by having to
asynchronously retrieve channels from the redis cache too.
Fixes #1053
|
| |
|
|
| |
Can be used to support rescheduling.
|
| |
|
|
|
|
|
| |
It was confusing to reject a silence and an unsilence when overwrites
were manually set to False. That's because it's contradictory to show
an error stating it's already silence but then reject an unsilence with
an error stating the channel isn't silenced.
|
| |
|
|
|
| |
Admins will have to manually check the default values used and adjust
them if they aren't the desired values for that particular channel.
|