aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py (unfollow)
Commit message (Collapse)AuthorLines
2020-11-14Migrate CI Pipeline to GitHub ActionsGravatar Sebastiaan Zeeff-251/+265
I've migrated our Azure CI Pipeline to GitHub Actions. While the general workflow is the same, there are a few changes: - `flake8` is no longer run by `pre-commit`, but rather by a separate action that adds annotations to the GH Action results page. - As we no longer have need for xml-formatted coverage files, the xmlrunner for unittest has been removed as a dependency. Instead, we now publish our coverage results to coveralls.io. - We use version 2 of docker's GitHub Action build-and-push flow, which is split over multiple steps instead of one. - I have changed the badges to GitHub Actions and coveralls.io badges. Note: Because we accept PRs from forks, we need to be a bit careful with our secrets. While we do use the `pull_request_target` event, we should not expose secrets in steps that run code from the repository. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-11-13CI: disable 'continueOnError'Gravatar kwzrd-2/+0
After #1219, we started to encounter issues with the cache being corrupted and CI failing due to 'pre-commit' not being installed after restore. Although it doesn't seem likely that this could have been the culprit, the issues began appearing shortly after merging the PR. Let's see what happens if we disable it.
2020-11-13CI: invalidate environment cacheGravatar kwzrd-1/+1
The cache was corrupted again for unknown reasons.
2020-11-11Config: ensure 2 blank lines between classesGravatar kwzrd-0/+3
Previous changes reduced the spacing to 1 blank line, which is inconsistent with the prevailing style.
2020-11-11CI: invalidate dependency cacheGravatar kwzrd-1/+1
The cache became corrupted for reasons what we were not able to figure out, causing the pre-commit step to fail when the environment was retrieved from the cache. By changing the key, we force cache rebuild.
2020-11-10Voice Gate: explain the purpose of `NO_MSG`Gravatar kwzrd-0/+4
2020-11-10Voice Gate: ensure atomicity when notifying usersGravatar kwzrd-20/+39
Previously, the listener risked yielding control to a racing event at multiple points between checking whether the member was already notified, notifying them, and writing this information into the cache. As a result, in a pathological case, multiple racing coroutines could have passed the membership check and ping-spammed the user, before the first coro could have a chance to write the message ID into the cache. In this commit, we move this logic into an atomic helper, which will ensure that events are processed one-by-one, and subsequent events correctly abort. Co-authored-by: MarkKoz <[email protected]> Co-authored-by: Sebastiaan Zeeff <[email protected]> Co-authored-by: Daniel Brown <[email protected]>
2020-11-10Voice Gate: define atomic `_delete_ping` functionGravatar kwzrd-11/+19
The code for ping deletion was duplicated in two places. In this commit, we move it into a helper function, and apply a lock to make each transaction atomic. This means that if two coroutines try to call the function, the first has to finish before the second can begin. This avoids the following: Coro1: Message in cache? Yes. Coro1: Send delete request. Yield control (await). Coro2: Message in cache? Yes. Now Coro2 has to wait for Coro1 to finish. Therefore it will always find the `NO_MSG` signal, and not attempt the deletion. Co-authored-by: MarkKoz <[email protected]> Co-authored-by: Sebastiaan Zeeff <[email protected]> Co-authored-by: Daniel Brown <[email protected]>
2020-11-09Voice Gate: correct after-delay message delete methodologyGravatar kwzrd-2/+5
Use a HTTP method so that we do not have to fetch the message object, the cache only gives us the ID.
2020-11-09Voice Gate: correct HTTP delete method usageGravatar kwzrd-4/+2
This removes the need to fetch the Channel object. Add a trace log to help with testing.
2020-11-08Voice Gate: refer to config rather than hard-coded durationGravatar kwzrd-1/+1
The const was introduced for this purpose, but it was accidentally not being used.
2020-11-08Voice Gate: fix cache membership checkGravatar kwzrd-2/+1
Since the cache offers a 'contains' coro, let's use it. If the member ID is already present in the cache, they were either already verified, or were already pung about not being verified.
2020-11-08Voice Gate: one-line func signatureGravatar kwzrd-7/+2
2020-11-08Added dummy parameter, changed message delete logicGravatar Daniel Brown-5/+9
- Added a None placeholder in the `__init__` for voice gate channel. - Changed deletion logic in on_voice_state_update to check if the message has already been deleted. - Changed deletion logic in voice_verify to only require one api call.
2020-11-06Detect codeblock language with special charactersGravatar Sebastiaan Zeeff-1/+1
The regex we use to detect codeblocks did not recognize language specifiers that use a dash, a plus, or a dot in their name. As there are valid language specifiers, such as python-repl and c++, that use those characters, I've changed the regex to reflect that. The character set used now reflects the characters used in language specifiers in highlight.js. Signed-off-by: Sebastiaan Zeeff <[email protected]>
2020-11-06Removed extra else's and added constantGravatar Daniel Brown-28/+29
- Removed unnecessary else statements - Added NO_MSG constant to replace the `False` that was being used previously in the redis cache. Signed-off-by: Daniel Brown <[email protected]>
2020-11-06Requested fixes - Various restructures of code.Gravatar Daniel Brown-29/+37
- Changed `VOICE_PING` constant to not contain the format brackets. - Added more detailed description of what the `redis_cache` will hold. - Changed message content verification to use the whole newly formatted `VOICE_PING` constant instead of a slice of it. - Added remaining parameters for the `on_voice_state_update` event for clarity. - Reorganized the logic of the `on_voice_state_update` for better clarity and better logging purposes. - Removed `_async_init` in favor of checking if the guild is ready inside the `on_voice_state_update` event. Verification channel is now loaded each time when needed, reducing risk of the object becoming stale or erroring out due to the not being ready before an event was triggered. Signed-off-by: Daniel Brown <[email protected]>
2020-11-05Corrected linting errors.Gravatar Daniel Brown-3/+2
Signed-off-by: Daniel Brown <[email protected]>
2020-11-05- Added ping deletion time to config file.Gravatar Daniel Brown-9/+19
- Added ping message constant to the top of the voice_gate.py file. - Corrected logic error in checking if a user is cached and in a voice channel. - Reduced default message deletion time to 1 minute from 5 minutes. - Adjusted on_message event to ignore the verification ping message. Signed-off-by: Daniel Brown <[email protected]>
2020-11-05Modified instructions for code block without langGravatar Amin Boukari-1/+1
2020-11-05Changed ```python to ```pyGravatar Amin Boukari-1/+1
2020-11-03Bug fixes, including improper cache calls, typos and moreGravatar Daniel Brown-10/+12
- Corrected spelling on _async_init call - Changed the None value stored in the cache if the user is already verified to False, as RedisCache doesn't support None. - Changed RedisCache type hint to reflect change made in storage style - Suppress NotFound errors when the ping_message can't be retrieved. - Corrected lack of await on send call More fixes to come. Signed-off-by: Daniel Brown <[email protected]>
2020-11-02Added ping message, message id storage and message deletionGravatar Daniel Brown-0/+23
- Users who have never joined the voice channels before (and are currently unverified) will receive a ping in the #voice_verification channel - If user is unverified, the message id is stored in the cache along with the user id. - Added a message deletion to the voiceverify command, which removes the ping message if one exists. Also sets stored message ID to None so that it doesn't attempt to delete messages that aren't there - Set timed message deletion for 5 minutes.
2020-11-02Added RedisCache and eventGravatar Daniel Brown-4/+23
- Added RedisCache instance as a class attribute of the VoiceGate cog. - Added voice_gate channel as an attribute to use it later in the cog. - Added cache type hint. Signed-off-by: Daniel Brown <[email protected]>
2020-11-01Actually fix the issue @kwzrd pointed outGravatar Joe Banks-3/+3
2020-11-01Correct 404 error message in voice gate commandGravatar Joe Banks-2/+2
2020-11-01Reinsert python-repl in PY_LANG_CODESGravatar Zach Gates-1/+1
2020-11-01Updated langs to include python-replGravatar Zach Gates-1/+1
2020-11-01Correct activity block config name in voice gate extensionGravatar Joe Banks-1/+1
2020-11-01Indent inline comment by two spaces in config-default.ymlGravatar Joe Banks-1/+1
2020-11-01Change wording of failure message and re-add trailing commaGravatar Joe Banks-1/+1
2020-11-01Remove full stopGravatar Joe Banks-1/+1
2020-10-31Add activity blocks threshold to voice gateGravatar Joe Banks-1/+4
2020-10-31Add new activity block constantGravatar Joe Banks-0/+2
2020-10-30Added method definition and needed imports.Gravatar Daniel Brown-1/+5
Signed-off-by: Daniel Brown <[email protected]>
2020-10-27Fix incorrect argument for _send_log when filtering evalsGravatar MarkKoz-1/+1
Fixes BOT-AN
2020-10-27"see here" -> "check this out"Gravatar Steele Farnsworth-1/+1
2020-10-26link to a page about finding the backtick key on different layouts.Gravatar Steele Farnsworth-1/+1
2020-10-26Made the message significantly shorterGravatar Steele-13/+3
2020-10-22Swapped individual channel ids for category id.Gravatar Daniel Brown-8/+4
Signed-off-by: Daniel Brown <[email protected]>
2020-10-22Update config-default.yml Gravatar Daniel Brown-1/+1
Changing a hyphen to an underscore in the config Co-authored-by: kwzrd <[email protected]>
2020-10-22Added voice_chat to eval listGravatar Daniel Brown-1/+9
Signed-off-by: Daniel Brown <[email protected]>
2020-10-22Update Python Discord badge to 100k members.Gravatar Dennis Pham-1/+1
2020-10-22Use FetchedMember for user annotationGravatar mbaruh-6/+7
2020-10-22Add handling of off-server users to user commandGravatar mbaruh-16/+23
2020-10-21Silence tests: update docstrings in notifier testsGravatar MarkKoz-2/+2
2020-10-21Relay python-dev to mailing lists channelGravatar Joe Banks-0/+1
2020-10-21Remove unnecessary getLogger callGravatar Numerlor-1/+0
2020-10-18Reminders: rename namespace constantGravatar MarkKoz-4/+4
It's better to have a self-documenting name than a comment, which, by the way, was using the old name for the decorator.
2020-10-18Silence: add locks to commandsGravatar MarkKoz-1/+9