Skip to content

Commit

Permalink
Tests for pubbot.github.receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k committed Sep 7, 2014
1 parent ce5262a commit fc86bd3
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pubbot/github/tests.py
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']
)

0 comments on commit fc86bd3

Please sign in to comment.