-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import mock | ||
import unittest | ||
|
||
from pubbot.github import receivers | ||
|
||
|
||
class TestPushToCommit(unittest.TestCase): | ||
|
||
def test_push(self): | ||
with mock.patch("pubbot.github.receivers.commit") as commit: | ||
payload = mock.Mock() | ||
payload.payload = { | ||
"commits": [ | ||
{"distinct": False}, | ||
{"distinct": True, "sha": "abc", "message": "hello", "author": {"name": "Pubbot"}}, | ||
] | ||
} | ||
receivers.push_to_commit(None, payload) | ||
|
||
commit.send.assert_called_with( | ||
revision="abc", | ||
message="hello", | ||
committer="Pubbot", | ||
) | ||
|
||
|
||
class TestPushToChat(unittest.TestCase): | ||
|
||
def test_push(self): | ||
with mock.patch("pubbot.github.receivers.say") as say: | ||
payload = mock.Mock() | ||
payload.repo = ('pubbothq', 'pubbot') | ||
payload.payload = { | ||
"commits": [ | ||
{"distinct": False}, | ||
{"distinct": True, "sha": "abc", "message": "hello", "author": {"name": "Pubbot"}}, | ||
] | ||
} | ||
receivers.push_to_chat(None, payload) | ||
|
||
say.assert_called_with( | ||
content="\x0303Pubbot \x0302pubbothq/pubbot \x0310abc\x0314\x0f: hello ...", | ||
tags=['github:pubbothq/pubbot'] | ||
) |