comparison venv/lib/python2.7/site-packages/github/tests/PullRequest.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 # -*- coding: utf-8 -*-
2
3 # ########################## Copyrights and license ############################
4 # #
5 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
6 # Copyright 2012 Zearin <zearin@gonk.net> #
7 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
8 # #
9 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
10 # #
11 # PyGithub is free software: you can redistribute it and/or modify it under #
12 # the terms of the GNU Lesser General Public License as published by the Free #
13 # Software Foundation, either version 3 of the License, or (at your option) #
14 # any later version. #
15 # #
16 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
18 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
19 # details. #
20 # #
21 # You should have received a copy of the GNU Lesser General Public License #
22 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
23 # #
24 # ##############################################################################
25
26 import Framework
27
28 import datetime
29
30
31 class PullRequest(Framework.TestCase):
32 def setUp(self):
33 Framework.TestCase.setUp(self)
34 self.repo = self.g.get_user().get_repo("PyGithub")
35 self.pull = self.repo.get_pull(31)
36
37 def testAttributes(self):
38 self.assertEqual(self.pull.additions, 511)
39 self.assertEqual(self.pull.assignee.login, "jacquev6")
40 self.assertEqual(self.pull.base.label, "jacquev6:topic/RewriteWithGeneratedCode")
41 self.assertEqual(self.pull.base.sha, "ed866fc43833802ab553e5ff8581c81bb00dd433")
42 self.assertEqual(self.pull.base.user.login, "jacquev6")
43 self.assertEqual(self.pull.base.ref, "topic/RewriteWithGeneratedCode")
44 self.assertEqual(self.pull.base.repo.full_name, "jacquev6/PyGithub")
45 self.assertEqual(self.pull.body, "Body edited by PyGithub")
46 self.assertEqual(self.pull.changed_files, 45)
47 self.assertEqual(self.pull.closed_at, datetime.datetime(2012, 5, 27, 10, 29, 7))
48 self.assertEqual(self.pull.comments, 1)
49 self.assertEqual(self.pull.commits, 3)
50 self.assertEqual(self.pull.created_at, datetime.datetime(2012, 5, 27, 9, 25, 36))
51 self.assertEqual(self.pull.deletions, 384)
52 self.assertEqual(self.pull.diff_url, "https://github.com/jacquev6/PyGithub/pull/31.diff")
53 self.assertEqual(self.pull.head.label, "BeaverSoftware:master")
54 self.assertEqual(self.pull.html_url, "https://github.com/jacquev6/PyGithub/pull/31")
55 self.assertEqual(self.pull.id, 1436215)
56 self.assertEqual(self.pull.issue_url, "https://github.com/jacquev6/PyGithub/issues/31")
57 self.assertFalse(self.pull.mergeable)
58 self.assertTrue(self.pull.merged)
59 self.assertEqual(self.pull.merged_at, datetime.datetime(2012, 5, 27, 10, 29, 7))
60 self.assertEqual(self.pull.merged_by.login, "jacquev6")
61 self.assertEqual(self.pull.number, 31)
62 self.assertEqual(self.pull.patch_url, "https://github.com/jacquev6/PyGithub/pull/31.patch")
63 self.assertEqual(self.pull.review_comments, 1)
64 self.assertEqual(self.pull.state, "closed")
65 self.assertEqual(self.pull.title, "Title edited by PyGithub")
66 self.assertEqual(self.pull.updated_at, datetime.datetime(2012, 11, 3, 8, 19, 40))
67 self.assertEqual(self.pull.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/31")
68 self.assertEqual(self.pull.user.login, "jacquev6")
69
70 def testCreateComment(self):
71 commit = self.repo.get_commit("8a4f306d4b223682dd19410d4a9150636ebe4206")
72 comment = self.pull.create_comment("Comment created by PyGithub", commit, "src/github/Issue.py", 5)
73 self.assertEqual(comment.id, 886298)
74
75 def testGetComments(self):
76 self.assertListKeyEqual(self.pull.get_comments(), lambda c: c.id, [886298])
77
78 def testCreateIssueComment(self):
79 comment = self.pull.create_issue_comment("Issue comment created by PyGithub")
80 self.assertEqual(comment.id, 8387331)
81
82 def testGetIssueComments(self):
83 self.assertListKeyEqual(self.pull.get_issue_comments(), lambda c: c.id, [8387331])
84
85 def testGetIssueComment(self):
86 comment = self.pull.get_issue_comment(8387331)
87 self.assertEqual(comment.body, "Issue comment created by PyGithub")
88
89 def testEditWithoutArguments(self):
90 self.pull.edit()
91
92 def testEditWithAllArguments(self):
93 self.pull.edit("Title edited by PyGithub", "Body edited by PyGithub", "open")
94 self.assertEqual(self.pull.title, "Title edited by PyGithub")
95 self.assertEqual(self.pull.body, "Body edited by PyGithub")
96 self.assertEqual(self.pull.state, "open")
97
98 def testGetCommits(self):
99 self.assertListKeyEqual(self.pull.get_commits(), lambda c: c.sha, ["4aadfff21cdd2d2566b0e4bd7309c233b5f4ae23", "93dcae5cf207de376c91d0599226e7c7563e1d16", "8a4f306d4b223682dd19410d4a9150636ebe4206"])
100
101 def testGetFiles(self):
102 self.assertListKeyEqual(self.pull.get_files(), lambda f: f.filename, ["codegen/templates/GithubObject.py", "src/github/AuthenticatedUser.py", "src/github/Authorization.py", "src/github/Branch.py", "src/github/Commit.py", "src/github/CommitComment.py", "src/github/CommitFile.py", "src/github/CommitStats.py", "src/github/Download.py", "src/github/Event.py", "src/github/Gist.py", "src/github/GistComment.py", "src/github/GistHistoryState.py", "src/github/GitAuthor.py", "src/github/GitBlob.py", "src/github/GitCommit.py", "src/github/GitObject.py", "src/github/GitRef.py", "src/github/GitTag.py", "src/github/GitTree.py", "src/github/GitTreeElement.py", "src/github/Hook.py", "src/github/Issue.py", "src/github/IssueComment.py", "src/github/IssueEvent.py", "src/github/Label.py", "src/github/Milestone.py", "src/github/NamedUser.py", "src/github/Organization.py", "src/github/Permissions.py", "src/github/Plan.py", "src/github/PullRequest.py", "src/github/PullRequestComment.py", "src/github/PullRequestFile.py", "src/github/Repository.py", "src/github/RepositoryKey.py", "src/github/Tag.py", "src/github/Team.py", "src/github/UserKey.py", "test/Issue.py", "test/IssueEvent.py", "test/ReplayData/Issue.testAddAndRemoveLabels.txt", "test/ReplayData/Issue.testDeleteAndSetLabels.txt", "test/ReplayData/Issue.testGetLabels.txt", "test/ReplayData/IssueEvent.setUp.txt"])
103
104 def testMerge(self):
105 self.assertFalse(self.pull.is_merged())
106 status = self.pull.merge()
107 self.assertEqual(status.sha, "688208b1a5a074871d0e9376119556897439697d")
108 self.assertTrue(status.merged)
109 self.assertEqual(status.message, "Pull Request successfully merged")
110 self.assertTrue(self.pull.is_merged())
111
112 def testMergeWithCommitMessage(self):
113 self.g.get_user().get_repo("PyGithub").get_pull(39).merge("Custom commit message created by PyGithub")