-
-
Notifications
You must be signed in to change notification settings - Fork 409
loader, plugin: remove deprecated features #2329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2125,10 +2125,7 @@ def handler(wrapped, trigger): | |
| assert result.group(1) == 'reverse' | ||
|
|
||
|
|
||
| def test_command_from_callable_regex_pattern(mockbot): | ||
| # TODO: this test must FAIL for Sopel 8.0 | ||
| # Command name as regex pattern will be removed in Sopel 8.0 | ||
|
|
||
| def test_command_from_callable_escaped_regex_pattern(mockbot): | ||
| # prepare callable | ||
| @plugin.commands('main .*') | ||
| def handler(wrapped, trigger): | ||
|
|
@@ -2139,21 +2136,23 @@ def handler(wrapped, trigger): | |
| # create rule from a cleaned callable | ||
| rule = rules.Command.from_callable(mockbot.settings, handler) | ||
|
|
||
| # match on ".main anything" | ||
| # does not match on ".main anything" | ||
| line = ':[email protected] PRIVMSG #sopel :.main anything' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
|
|
||
| assert not results, 'Regex commands are not allowed since Sopel 8.0' | ||
|
|
||
| # match on ".main .*" | ||
| line = ':[email protected] PRIVMSG #sopel :.main .*' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
|
|
||
| assert len(results) == 1, ( | ||
| 'Exactly 1 command must match; MUST fail for Sopel 8.0') | ||
| 'Command name must be escaped to get an exact match') | ||
| result = results[0] | ||
| assert result.group(0) == '.main anything' | ||
| assert result.group(1) == 'main anything' | ||
| assert result.group(2) is None | ||
| assert result.group(3) is None | ||
| assert result.group(4) is None | ||
| assert result.group(5) is None | ||
| assert result.group(6) is None | ||
| assert result.group(0) == '.main .*' | ||
| assert result.group(1) == 'main .*' | ||
|
|
||
|
|
||
| def test_command_from_callable_invalid(mockbot): | ||
|
|
@@ -2169,21 +2168,6 @@ def handler(wrapped, trigger): | |
| rules.Command.from_callable(mockbot.settings, handler) | ||
|
|
||
|
|
||
| def test_command_escape_name(): | ||
| rule = rules.Command('hello', r'\.', plugin='testplugin') | ||
|
|
||
| assert rule.escape_name('hello') == 'hello' | ||
| assert rule.escape_name('hello world') == r'hello\ world' | ||
| assert rule.escape_name(r'hello\ world') == r'hello\ world', ( | ||
| 'Valid pattern must not be escaped') | ||
| assert rule.escape_name(r'.*') == r'.*', ( | ||
| 'Valid pattern must not be escaped') | ||
| assert rule.escape_name(r'a[bc]d') == r'a[bc]d', ( | ||
| 'Valid pattern must not be escaped') | ||
| assert rule.escape_name(r'hello(') == r'hello\(', ( | ||
| 'Invalid pattern must be escaped') | ||
|
|
||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # tests for :class:`sopel.plugins.rules.NickCommand` | ||
|
|
||
|
|
@@ -2444,10 +2428,6 @@ def handler(wrapped, trigger): | |
|
|
||
|
|
||
| def test_nick_command_from_callable_regex_pattern(mockbot): | ||
| # TODO: this test must FAIL for Sopel 8.0 | ||
| # Command name as regex pattern will be removed in Sopel 8.0 | ||
|
|
||
| # prepare callable | ||
| @plugin.nickname_commands('do .*') | ||
| def handler(wrapped, trigger): | ||
| wrapped.reply('Hi!') | ||
|
|
@@ -2457,16 +2437,21 @@ def handler(wrapped, trigger): | |
| # create rule from a cleaned callable | ||
| rule = rules.NickCommand.from_callable(mockbot.settings, handler) | ||
|
|
||
| # match on ".main anything" | ||
| # does not match on ".do anything" | ||
| line = ':[email protected] PRIVMSG #sopel :TestBot: do anything' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
|
|
||
| assert len(results) == 1, ( | ||
| 'Exactly 1 command must match; MUST fail for Sopel 8.0') | ||
| assert not results, 'Regex commands are not allowed since Sopel 8.0' | ||
|
|
||
| # match on ".do .*" | ||
| line = ':[email protected] PRIVMSG #sopel :TestBot: do .*' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
| assert len(results) == 1, 'Exactly 1 command must match' | ||
| result = results[0] | ||
| assert result.group(0) == 'TestBot: do anything' | ||
| assert result.group(1) == 'do anything' | ||
| assert result.group(0) == 'TestBot: do .*' | ||
| assert result.group(1) == 'do .*' | ||
| assert result.group(2) is None | ||
| assert result.group(3) is None | ||
| assert result.group(4) is None | ||
|
|
@@ -2649,9 +2634,6 @@ def handler(wrapped, trigger): | |
|
|
||
|
|
||
| def test_action_command_from_callable_regex_pattern(mockbot): | ||
| # TODO: this test must FAIL for Sopel 8.0 | ||
| # Command name as regex pattern will be removed in Sopel 8.0 | ||
|
|
||
| # prepare callable | ||
| @plugin.action_commands('do .*') | ||
| def handler(wrapped, trigger): | ||
|
|
@@ -2662,16 +2644,22 @@ def handler(wrapped, trigger): | |
| # create rule from a cleaned callable | ||
| rule = rules.ActionCommand.from_callable(mockbot.settings, handler) | ||
|
|
||
| # match on ".main anything" | ||
| # does not match on ".do anything" | ||
| line = ':[email protected] PRIVMSG #sopel :\x01ACTION do anything\x01' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
|
|
||
| assert len(results) == 1, ( | ||
| 'Exactly 1 command must match; MUST fail for Sopel 8.0') | ||
| assert not results, 'Regex commands are not allowed since Sopel 8.0' | ||
|
|
||
| # match on ".do .*" | ||
| line = ':[email protected] PRIVMSG #sopel :\x01ACTION do .*\x01' | ||
| pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
| results = list(rule.match(mockbot, pretrigger)) | ||
|
|
||
| assert len(results) == 1, 'Exactly 1 command must match' | ||
| result = results[0] | ||
| assert result.group(0) == 'do anything' | ||
| assert result.group(1) == 'do anything' | ||
| assert result.group(0) == 'do .*' | ||
| assert result.group(1) == 'do .*' | ||
| assert result.group(2) is None | ||
| assert result.group(3) is None | ||
| assert result.group(4) is None | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.