def process_github_pr_event(self, payload): pr_event = PullRequestEvent() pr_event.load(payload) self.log.debug("PR event is: %s" % pr_event) return_msg = self.get_pr_event_irc_notification_msg(pr_event) self.log.debug("PR event IRC msg: %s" % return_msg) return return_msg
class TestPullRequestEvent(unittest.TestCase): def setUp(self): self.ghpre = PullRequestEvent() def test_default_setup(self): self.assertEqual(self.ghpre.action, "<No Action Specified>") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest()) self.assertEqual(self.ghpre.sender, GithubUser()) def test_load_empty_secondary_objects(self): payload = {} self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "<No Action Specified>") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest()) self.assertEqual(self.ghpre.sender, GithubUser()) def test_non_empty_pr(self): payload = {"action": "sleep", "pull_request": {"title": "new pr"}} self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "sleep") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr")) self.assertEqual(self.ghpre.sender, GithubUser()) def test_non_empty_sender(self): payload = { "action": "sleep", "number": "42", "pull_request": { "title": "new pr" }, "sender": { "login": "******" } } self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "sleep") self.assertEqual(self.ghpre.number, "42") self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr")) self.assertEqual(self.ghpre.sender, GithubUser(login="******"))
class TestPullRequestEvent(unittest.TestCase): def setUp(self): self.ghpre = PullRequestEvent() def test_default_setup(self): self.assertEqual(self.ghpre.action, "<No Action Specified>") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest()) self.assertEqual(self.ghpre.sender, GithubUser()) def test_load_empty_secondary_objects(self): payload = {} self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "<No Action Specified>") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest()) self.assertEqual(self.ghpre.sender, GithubUser()) def test_non_empty_pr(self): payload = {"action": "sleep", "pull_request": {"title": "new pr"}} self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "sleep") self.assertEqual(self.ghpre.number, "") self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr")) self.assertEqual(self.ghpre.sender, GithubUser()) def test_non_empty_sender(self): payload = { "action": "sleep", "number": "42", "pull_request": {"title": "new pr"}, "sender": {"login": "******"}, } self.ghpre.load(payload) self.assertEqual(self.ghpre.action, "sleep") self.assertEqual(self.ghpre.number, "42") self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr")) self.assertEqual(self.ghpre.sender, GithubUser(login="******"))
def setUp(self): self.ghpre = PullRequestEvent()