-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: unit tests around protocol usage (#48)
* chore: removing unused protocol * improve naming * Add the default * Improve based on feedback
- Loading branch information
1 parent
d048022
commit b5ed2b2
Showing
21 changed files
with
104 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import logging | ||
|
||
from .protocol import Protocol | ||
|
||
|
||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from unittest.mock import Mock | ||
|
||
from slack_cli_hooks.protocol.protocol import Protocol | ||
|
||
|
||
def debug(self, msg: str, *args, **kwargs): | ||
"""This is a mock""" | ||
pass | ||
|
||
|
||
def info(self, msg: str, *args, **kwargs): | ||
"""This is a mock""" | ||
pass | ||
|
||
|
||
def warning(self, msg: str, *args, **kwargs): | ||
"""This is a mock""" | ||
pass | ||
|
||
|
||
def error(self, msg: str, *args, **kwargs): | ||
"""This is a mock""" | ||
pass | ||
|
||
|
||
def respond(self, data: str): | ||
"""This is a mock""" | ||
pass | ||
|
||
|
||
class MockProtocol(Protocol): | ||
name: str = "MockProtocol" | ||
|
||
debug = Mock(spec=debug, return_value=None) | ||
info = Mock(spec=info, return_value=None) | ||
warning = Mock(spec=warning, return_value=None) | ||
error = Mock(spec=error, return_value=None) | ||
respond = Mock(spec=respond, return_value=None) |
This file contains 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import re | ||
|
||
from slack_cli_hooks.hooks.get_hooks import hooks_payload | ||
|
||
|
||
|
This file contains 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 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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
from slack_cli_hooks.protocol import build_protocol, DefaultProtocol, MessageBoundaryProtocol, Protocol | ||
from slack_cli_hooks.protocol import MessageBoundaryProtocol, Protocol, build_protocol | ||
from slack_cli_hooks.protocol.default_protocol import DefaultProtocol | ||
|
||
|
||
class TestProtocolFactory: | ||
def test_default(self): | ||
args = [] | ||
protocol = build_protocol(args) | ||
protocol = build_protocol(argv=args) | ||
assert isinstance(protocol, Protocol) | ||
assert isinstance(protocol, DefaultProtocol) | ||
|
||
def test_message_boundaries(self): | ||
args = [f"--protocol={MessageBoundaryProtocol.name}", "--bound=boundary"] | ||
protocol = build_protocol(args) | ||
protocol = build_protocol(argv=args) | ||
assert isinstance(protocol, Protocol) | ||
assert isinstance(protocol, MessageBoundaryProtocol) |