aboutsummaryrefslogtreecommitdiffstats
path: root/tests (follow)
Commit message (Collapse)AuthorAgeLines
...
| | * | | | | | Test TokenRemover.format_log_messageGravatar MarkKoz2020-05-11-0/+16
| | | | | | | |
| | * | | | | | Test token remover's message deletionGravatar MarkKoz2020-05-11-0/+9
| | | | | | | |
| | * | | | | | Simplify token remover's message mockGravatar MarkKoz2020-05-11-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Rely on default values for the author * Set the content to a non-empty string
| | * | | | | | Avoid instantiating the cog when testing static/class methodsGravatar MarkKoz2020-05-11-10/+5
| | | | | | | |
| | * | | | | | Correct the return type annotation for the autospec decoratorGravatar MarkKoz2020-05-11-2/+2
| | | | | | | |
| | * | | | | | Test token regex matches valid tokensGravatar MarkKoz2020-05-11-0/+21
| | | | | | | |
| | * | | | | | Test is_maybe_tokenGravatar MarkKoz2020-05-11-7/+24
| | | | | | | |
| | * | | | | | Test `is_maybe_token` returns False for missing partsGravatar MarkKoz2020-05-11-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practice, this won't ever happen since the regex wouldn't match strings with missing parts. However, the function does check it so may as well test it. It's not necessarily bound to always use inputs from the regex either I suppose.
| | * | | | | | Fix autospec decorator when used with multiple attributesGravatar MarkKoz2020-05-11-16/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original approach of messing with the `attribute_name` didn't work for reasons I won't discuss here (would require knowledge of patcher internals). The new approach doesn't use patch.multiple but mimics it by applying multiple patch decorators to the function. As a consequence, this can no longer be used as a context manager.
| | * | | | | | Test token regex doesn't match invalid tokensGravatar MarkKoz2020-05-11-7/+25
| | | | | | | |
| | * | | | | | Test `find_token_in_message` returns the found tokenGravatar MarkKoz2020-05-11-0/+24
| | | | | | | |
| | * | | | | | Test `find_token_in_message` returns None if no matches foundGravatar MarkKoz2020-05-11-0/+14
| | | | | | | |
| | * | | | | | Fix test for token remover ignoring bot messagesGravatar MarkKoz2020-05-11-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's not possible to test this via asserting the return value of `on_message` since it never returns anything. Instead, the actual relevant unit, `find_token_in_message,` should be tested.
| | * | | | | | Allow using arbitrary parameter names with the autospec decoratorGravatar MarkKoz2020-05-11-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gives the caller more flexibility. Sometimes attribute names are too long or they don't follow a naming scheme accepted by the linter.
| | * | | | | | Test token remover skips messages without tokensGravatar MarkKoz2020-05-11-0/+11
| | | | | | | |
| | * | | | | | Test token remover takes action if a token is foundGravatar MarkKoz2020-05-11-1/+13
| | | | | | | |
| | * | | | | | Add a test helper function to patch multiple attributes with autospecsGravatar MarkKoz2020-05-11-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This helper reduces redundancy/boilerplate by setting default values. It also has the consequence of shortening the length of the invocation, which makes it faster to use and easier to read.
| | * | | | | | Test on_message_edit of token remover uses on_messageGravatar MarkKoz2020-05-11-2/+10
| | | | | | | |
| * | | | | | | Merge pull request #978 from ItsDrike/unsilence-schedulerGravatar Mark2020-06-12-4/+14
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Use Scheduler instead of asyncio.sleep on silence cog
| | * | | | | | | Test for channel not silenced messageGravatar ItsDrike2020-06-06-4/+14
| | | |_|_|_|/ / | | |/| | | | |
| * | | | | | | Merge branch 'master' into bad-words-nickGravatar ks1292020-06-11-60/+317
| |\ \ \ \ \ \ \
| | * \ \ \ \ \ \ Merge branch 'master' into bug/backend/906/converter-year-rangeGravatar Joseph Banks2020-06-10-47/+824
| | |\ \ \ \ \ \ \ | | | | |_|_|_|_|/ | | | |/| | | | |
| | | * | | | | | Merge branch 'master' into staff_count_serverGravatar kwzrd2020-06-05-5/+0
| | | |\ \ \ \ \ \ | | | | | |_|/ / / | | | | |/| | | |
| | | * | | | | | Merge branch 'master' into staff_count_serverGravatar Leon Sandøy2020-05-31-0/+247
| | | |\ \ \ \ \ \ | | | | | |/ / / / | | | | |/| | | |
| | | * | | | | | Fix busted test_information test.Gravatar Leon Sandøy2020-05-30-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I wish this test didn't exist.
| | * | | | | | | Fix exception message assertions in converter testsGravatar MarkKoz2020-04-28-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `msg` arg is for displaying a message when the assertion fails. To match against the exception's message, `assertRaisesRegex` must be used. Since all of the messages are meant to be interpreted literally rather than as regex, `re.escape` is used.
| | * | | | | | | Use await instead of asyncio.run in converter testsGravatar MarkKoz2020-04-28-28/+27
| | | | | | | | |
| | * | | | | | | Remove redundant parenthesis from test valuesGravatar MarkKoz2020-04-28-19/+19
| | | | | | | | |
| | * | | | | | | Test for out of range datetime in the Duration converterGravatar MarkKoz2020-04-28-0/+11
| | | | | | | | |
| * | | | | | | | Remove redis namespace collision testGravatar MarkKoz2020-05-31-10/+0
| | |/ / / / / / | |/| | | | | |
* | | | | | | | In LinePaginator, truncate words that exceed scale_to_sizeGravatar Kyle Stanley2020-06-26-7/+5
| | | | | | | |
* | | | | | | | Update LinePaginator.add_line() testsGravatar Kyle Stanley2020-06-26-5/+5
| | | | | | | |
* | | | | | | | Merge branch 'master' into issue926-paginate-long-linesGravatar Kyle Stanley2020-06-04-40/+645
|\ \ \ \ \ \ \ \ | | |_|_|/ / / / | |/| | | | | |
| * | | | | | | Merge branch 'master' into stop_sending_avatar_hashGravatar Leon Sandøy2020-05-31-31/+638
| |\ \ \ \ \ \ \ | | | |_|/ / / / | | |/| | | | |
| | * | | | | | Merge branch 'master' into ban-kick-reason-lengthGravatar Mark2020-05-30-31/+550
| | |\ \ \ \ \ \
| | | * | | | | | Merge branch 'master' into test_antimalwareGravatar Sebastiaan Zeeff2020-05-30-35/+398
| | | |\| | | | |
| | | | * | | | | Add custom exceptions for each error state.Gravatar Leon Sandøy2020-05-28-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | Merge branch 'master' into redis_persistenceGravatar Leon Sandøy2020-05-27-10/+49
| | | | |\ \ \ \ \
| | | | | * | | | | Add some tests for `in_whitelist_check`.Gravatar Leon Sandøy2020-05-27-0/+48
| | | | | | | | | |
| | | | | * | | | | Remove the now deprecated in_channel_check.Gravatar Leon Sandøy2020-05-27-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check was no longer being used anywhere, having been replaced by in_whitelist_check.
| | | | | * | | | | Find + change all InWhitelistCheckFailure importsGravatar Leon Sandøy2020-05-27-2/+1
| | | | | | | | | |
| | | | | * | | | | Refactor the in_whitelist deco to a check.Gravatar Leon Sandøy2020-05-27-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | | Floats are no longer permitted as RedisCache keys.Gravatar Leon Sandøy2020-05-27-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | | Refactor .increment and add lock test.Gravatar Leon Sandøy2020-05-27-64/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * | | | | | Clear cache in asyncSetUp instead of tests.Gravatar Leon Sandøy2020-05-27-6/+1
| | | | | | | | | |
| | | | * | | | | | Add a test for RuntimeErrors.Gravatar Leon Sandøy2020-05-26-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.
| | | | * | | | | | Improve output of section name in config validation subtestsGravatar MarkKoz2020-05-25-1/+1
| | | | | | | | | |
| | | | * | | | | | Support validating collection types for constantsGravatar MarkKoz2020-05-25-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a simple validation that only check the type of the collection. It does not validate the types inside the collection because that has proven to be quite complex.
| | | | * | | | | | Add support for Union type annotations for constantsGravatar MarkKoz2020-05-24-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that `Optional[x]` is just an alias for `Union[None, x]` so this effectively supports `Optional` too. This was especially troublesome because the redis password must be unset/None in order to avoid authentication, but the test would complain that `None` isn't a `str`. Setting to an empty string would pass the test but then make redis authenticate and fail.
| | | | * | | | | | Improve error and error testing for incrementGravatar Leon Sandøy2020-05-24-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed a RuntimeError to a KeyError (thanks @MarkKoz), and also added some tests to ensure that the right errors are raised whenever this method is used incorrectly.