Repository navigation
Add test cases for antispam rules, fix bug in attachments rule & test - #733
Conversation
The rule was incorrectly printing out the maximum amount of allowed attachments instead of the configured interval. This commit also adjusts the rule's unit test case.
The name msg is less descriptive and creates a needless name conflict in local gen exp.
|
The committed code is considered ready for review. I'm currently awaiting a response from a user in #599 - if they're no longer interested, I'd like to include that issue in this PR's scope as well. |
MarkKoz
left a comment
There was a problem hiding this comment.
Most of the code for the tests is extremely similar, even the cases (the burst tests are kind of outliers). The main difference is always just in the make_msg function and the output string.
|
The test cases are similar, yes - the rules are too. What do you propose can be done to make this better? Would it make sense to implement some kind of an "executor" on the side, and then just feed it the test cases from each module? |
|
Two helper functions: one for "allows" tests and one for "disallows". They should be passed the As I mentioned, some of the subtest arguments follow a similar pattern across test suites. To facilitate this, a function could be defined which will take a I believe such a design will reduce redundancy but still remain flexible should test suites need to diverge in code in the future. |
This will serve as an ABC for tests for individual rules. The base class provides runners for allowed and disallowed cases, and the children classes then only provide the cases and implementations of helper methods specific to each rule.
This will prevent child classes to be instantiated unless they implement all abstract methods, leading to a more descriptive error message.
|
93d19f3 adds an ABC (9758e32 actually adds the Let me know how this looks, and thanks for the feedback. |
|
I've added tests for As the latter is more complex than the other rules, yielding two distinct error reports, I decided to implement two subclasses of the If the given messages violate both total count and max consecutive, the rule will fail on the total as that is checked first. Since I consider this an implementation detail and not "desired functionality", I do not test it, and each disallowed test case only violates the rule one way or the other, so that the tests still pass should the two checks switch order. This PR now provides 100% coverage for the entire |
This PR introduces a series of unit test cases for the bot's antispam rules. This addresses the following issues.
Closes #595 via 1f17d0e.
Closes #596 via b0713be.
Closes #597 via f15f318.
Closes #598 via 4bfe30d.
Closes #603 via f32ffaf.
I also sneak in a quick bugfix in 4199b12: it appears that the already existing rule for attachments contains a slight bug where in the printout, the configured
'max'key is looked up instead of'interval'. The same commit also fixes the key in the rule's unit test, which was incorrectly expecting the wrong key.Finally, aedbd6f is a refactor of the name
msgintomake_msgwhich prevents a harmless, but unnecessary name collision in themsg for msg in ...generator expressions down the module.Edit:
Closes #599 via 54e8c98.
Closes #602 via cae7f25.