aboutsummaryrefslogtreecommitdiffstats
path: root/tests/base.py (unfollow)
Commit message (Collapse)AuthorLines
2020-06-29Add option for user to delete the not found message before it's auto deleted.Gravatar Numerlor-4/+11
2020-06-29Trigger typing in converter instead of command.Gravatar Numerlor-4/+2
The converter does a web request so triggering typing in the command itself left out a period where the bot seemed inactive.
2020-06-29Add stat for packages of fetched symbols.Gravatar Numerlor-10/+13
An additional variable is added to the DocItem named tuple to accommodate this. The `_package_name` is separated from `api_package_name` it previously overwrote and is now used for the stats and renamed symbols because the names are in a friendlier format.
2020-06-28Only update added inventory instead of all.Gravatar Numerlor-1/+1
2020-06-27Only include one newline for `p` tags in `li` elements.Gravatar Numerlor-0/+7
2020-06-27Redesign `find_all_text_until_tag` to search through all direct children.Gravatar Numerlor-27/+12
The previous approach didn't work for arbitrary tags with text.
2020-06-21Strip backticks from symbol input.Gravatar Numerlor-0/+1
This allows the user to wrap symbols in codeblocks to avoid markdown.
2020-06-21Correct return when a module symbol could not be parsed.Gravatar Numerlor-9/+8
2020-06-21Fix typehint.Gravatar Numerlor-1/+1
2020-06-21Renamed existing symbols from `NO_OVERRIDE_GROUPS` instead of replacing.Gravatar Numerlor-7/+12
Before, when a symbol from the group shared the name with a symbol outside of it the symbol was simply replaced and lost. The new implementation renames the old symbols to the group_name.symbol format before the new symbol takes their place.
2020-06-21Add symbol group name to symbol inventory entries.Gravatar Numerlor-10/+17
2020-06-21Remove unnecessary join.Gravatar Numerlor-1/+1
`find_all_text_until_tag` already returns a string so a join is not needed.
2020-06-21Also check signatures before selected symbol when collecting 3 signatures.Gravatar Numerlor-1/+5
2020-06-21Account for `NavigableString`s when gathering text.Gravatar Numerlor-3/+9
`find_next()` only goes to tags, leaving out text outside of them when parsing.
2020-06-18Make sure only class contents are included, without methods.Gravatar Numerlor-13/+42
When parsing classes, methods would sometimes get included causing bad looking markdown to be included in the description, this is solved by collecting all text *up to* the next dt tag. fixes: #990
2020-06-18Move symbol parsing into separate methods.Gravatar Numerlor-23/+43
2020-06-17Skip symbols with slashes in them.Gravatar Numerlor-0/+2
The symbols mostly point to autogenerated pages, and do not link to specific symbols on their pages and are thus unreachable with the current implementation.
2020-06-17Make doc get greedy.Gravatar Numerlor-5/+6
This allows us to find docs for symbols with spaces in them.
2020-06-17Resolve relative href urls in a html elements.Gravatar Numerlor-3/+13
Most docs will use relative urls to link across their pages, without resolving them ourselves the links remain unusable in discord's markdown and break out of codeblocks on mobile.
2020-05-30Tags: explicitly use UTF-8 to read filesGravatar MarkKoz-1/+1
Not all operating systems use UTF-8 as the default encoding. For systems that don't, reading tag files with Unicode would cause an unhandled exception. (cherry picked from commit adc75ff9bbcf8b905bd78c78f253522ae5e42fc3)
2020-05-29Reduce the number of help channel name changesGravatar Sebastiaan Zeeff-29/+3
Discord has introduced a new, strict rate limit for individual channel edits that reduces the number of allow channel name/channel topic changes to 2 per 10 minutes per channel. Unfortunately, our help channel system frequently goes over that rate limit as it edits the name and topic of a channel on all three "move" actions we have: to available, to occupied, and to dormant. In addition, our "unanswered" feature adds another channel name change on top of the move-related edits. That's why I've removed the topic/emoji changing features from the help channel system. This means we now have a generic topic that fits all three categories and no status emojis in the channel names.
2020-05-29Fix `check_for_answer` breaking on missing cacheGravatar Sebastiaan Zeeff-2/+5
The `check_for_answer` method of the HelpChannels cog relies on the channel->claimant cache being available. However, as this cache is (currently) lost during bot restarts, this method may fail with a KeyError exception. I've used `dict.get` with an `if not claimant: return` to circumvent this issue.
2020-05-29Ignore response when posting python newsGravatar Matteo Bertucci-0/+1
Sometimes a mailing list user doesn't press respond correctly to the email, and so a response is sent as a separate thread. To keep only new threads in the channel, we need to ignore those.
2020-05-28Move the `self.redis_closed` into session create.Gravatar Leon Sandøy-1/+1
2020-05-28Prevent a state where a coro could wait forever.Gravatar Leon Sandøy-2/+6
This addresses a review comment by @aeros.
2020-05-28Add custom exceptions for each error state.Gravatar Leon Sandøy-8/+21
The bot can get into trouble in three distinct ways: - It has no Bot instance - It has no namespace - It has no parent instance. These happen only if you're using it wrong. To make the test more precise, and to add a little bit more readability (RuntimeError could be anything!), we'll introduce some custom exceptions for these three states. This addresses a review comment by @aeros.
2020-05-28Make prefix consts private and more precise.Gravatar Leon Sandøy-9/+9
2020-05-28Reduce complexity on some of the typestring stuff.Gravatar Leon Sandøy-31/+9
- Refactor error messages in _to_typestring and _from_typestring to just print the prefix tuples instead of that custom error string. - Create a RedisKeyOrValue type to simplify some annotations. - Simplify partialmethod calls. - Make the signatures for _to_typestring and _from_typestring one-liners - Fix a typo in the errors.
2020-05-27Fix ATROCIOUS comment.Gravatar Leon Sandøy-3/+5
I should be shot.
2020-05-27Refactor typestring converters to partialmethods.Gravatar Leon Sandøy-30/+24
We're using functools.partialmethod to make the code a little cleaner and more readable here. Read more about them here: https://docs.python.org/3/library/functools.html#functools.partial https://docs.python.org/3/library/functools.html#functools.partialmethod
2020-05-27Floats are no longer permitted as RedisCache keys.Gravatar Leon Sandøy-43/+86
Also added a test for this. This is the DRYest approach I could find. It's a little ugly, but I think it's probably good enough.
2020-05-27Add some tests for `in_whitelist_check`.Gravatar Leon Sandøy-0/+48
2020-05-27Remove the now deprecated in_channel_check.Gravatar Leon Sandøy-16/+0
This check was no longer being used anywhere, having been replaced by in_whitelist_check.
2020-05-27Refactor .increment and add lock test.Gravatar Leon Sandøy-65/+109
The way we were doing the asyncio.Lock() stuff for increment was slightly problematic. @aeros has adviced us that it's better to just initialize the lock as None in __init__, and then initialize it inside the first coroutine that uses it instead. This ensures that the correct loop gets attached to the lock, so we don't end up getting errors like this one: RuntimeError: got Future <Future pending> attached to a different loop This happens because the lock and the actual calling coroutines aren't on the same loop. When creating a new test, test_increment_lock, we discovered that we needed a small refactor here and also in the test class to make this new test pass. So, now we're creating a DummyCog for every test method, and this will ensure the loop streams never cross. Cause we all know we must never cross the streams.
2020-05-27Clear cache in asyncSetUp instead of tests.Gravatar Leon Sandøy-6/+1
2020-05-27Allow some commands to fail checks silently.Gravatar Leon Sandøy-2/+9
For example, we don't want the mod commands to produce any kind of error message when run by ordinary users in regular channels - these should have the perception of being invisible and unavailable.
2020-05-27No redirect for mod management.Gravatar Leon Sandøy-0/+1
2020-05-27Find + change all InWhitelistCheckFailure importsGravatar Leon Sandøy-9/+8
2020-05-27Allow infraction management in modmail categoryGravatar Leon Sandøy-12/+13
2020-05-27Refactor the in_whitelist deco to a check.Gravatar Leon Sandøy-53/+86
We're moving the actual predicate into the `utils.checks` folder, just like we're doing with most of the other decorators. This is to allow us the flexibility to use it as a pure check, not only as a decorator. This commit doesn't actually change any functionality, just moves it around.
2020-05-26Add /r/FlutterDev to the guild invite whitelistGravatar Dennis Pham-0/+1
2020-05-26Add a test for RuntimeErrors.Gravatar Leon Sandøy-0/+22
This just tests that the various RuntimeErrors are reachable - that includes the error about not having a bot instance, the one about not being a class attribute, and the one about not having instantiated the class. This test addresses a concern raised by @MarkKoz in a review. I've decided not to test that actual contents of these RuntimeErrors, because I believe that sort of testing is a bit too brittle. It shouldn't break a test just to change the content of an error string.
2020-05-26Swap the order for the validate_cache checks.Gravatar Leon Sandøy-8/+8
2020-05-26Improve some docstrings for RedisCache.Gravatar Leon Sandøy-5/+3
Thanks @MarkKoz!
2020-05-26Make self.increment_lock private.Gravatar Leon Sandøy-2/+2
2020-05-26Add better docstring for RedisCache.updateGravatar Leon Sandøy-2/+12
2020-05-26Fix edge case where pop might not delete.Gravatar Leon Sandøy-6/+6
If you passed a key for a value that was the same as your optional, it would just return it but not delete it. This edge case isn't worth it, so I'm just removing that condition and letting the extra API call fly.
2020-05-26Turn log.exception into log.errorGravatar Leon Sandøy-17/+22
Also, refactor error messages to be consistent and DRY throughout the file.
2020-05-26[stats] Do not report modmail channels to statsGravatar Joseph Banks-1/+11
2020-05-25Expose the redis port to the hostGravatar MarkKoz-0/+2
Useful for those that run redis with docker-compose but not the bot. The bot on the host won't have access to the Docker network in such case so the port must be exposed.