|
5 | 5 | fromgithub3importGitHubError
|
6 | 6 | fromgithub3.nullimportNullObject
|
7 | 7 | fromgithub3.repos.repoimportRepository
|
| 8 | +fromgithub3.modelsimportGitHubCore |
8 | 9 |
|
9 | 10 | from .importhelper
|
10 | 11 |
|
@@ -248,19 +249,65 @@ def test_create_milestone_accepted_state(self):
|
248 | 249 | }
|
249 | 250 | )
|
250 | 251 |
|
251 |
| -deftest_create_pull(self): |
| 252 | +deftest_create_pull_private_required_data(self): |
| 253 | +"""Verify the request for creating a pull request.""" |
| 254 | +withhelper.mock.patch.object(GitHubCore,'_remove_none')asrm_none: |
| 255 | +data= {} |
| 256 | +self.instance._create_pull(data) |
| 257 | +rm_none.assert_called_once_with({}) |
| 258 | +assertself.session.post.calledisFalse |
| 259 | + |
| 260 | +deftest_create_pull_private(self): |
252 | 261 | """Verify the request for creating a pull request."""
|
253 | 262 | data= {
|
254 | 263 | 'title':'foo',
|
255 | 264 | 'base':'master',
|
256 | 265 | 'head':'feature_branch'
|
257 | 266 | }
|
258 |
| -self.instance.create_pull(**data) |
| 267 | +self.instance._create_pull(data) |
259 | 268 | self.post_called_with(
|
260 | 269 | url_for('pulls'),
|
261 | 270 | data=data
|
262 | 271 | )
|
263 | 272 |
|
| 273 | +deftest_create_pull(self): |
| 274 | +"""Verify the request for creating a pull request.""" |
| 275 | +data= { |
| 276 | +'title':'foo', |
| 277 | +'base':'master', |
| 278 | +'head':'feature_branch', |
| 279 | +'body':'body' |
| 280 | + } |
| 281 | +withhelper.mock.patch.object(Repository,'_create_pull')aspull: |
| 282 | +self.instance.create_pull(**data) |
| 283 | +pull.assert_called_once_with( |
| 284 | +data |
| 285 | + ) |
| 286 | + |
| 287 | +deftest_create_pull_from_issue(self): |
| 288 | +"""Verify the request for creating a pull request from an issue.""" |
| 289 | +withhelper.mock.patch.object(Repository,'_create_pull')aspull: |
| 290 | +data= { |
| 291 | +'issue':1, |
| 292 | +'base':'master', |
| 293 | +'head':'feature_branch' |
| 294 | + } |
| 295 | +self.instance.create_pull_from_issue( |
| 296 | +**data |
| 297 | + ) |
| 298 | +pull.assert_called_once_with(data) |
| 299 | + |
| 300 | +deftest_create_pull_from_issue_required_issue_number(self): |
| 301 | +"""Verify the request for creating a pull request from an issue.""" |
| 302 | +withhelper.mock.patch.object(Repository,'_create_pull')aspull: |
| 303 | +pull_request=self.instance.create_pull_from_issue( |
| 304 | +issue=-1, |
| 305 | +base='master', |
| 306 | +head='feature_branch' |
| 307 | + ) |
| 308 | +assertpull.calledisFalse |
| 309 | +assertpull_requestisNone |
| 310 | + |
264 | 311 | deftest_create_ref(self):
|
265 | 312 | """Verify the request to create a reference."""
|
266 | 313 | self.instance.create_ref('refs/heads/foo','my-fake-sha')
|
@@ -903,6 +950,17 @@ def test_create_pull(self):
|
903 | 950 | withpytest.raises(GitHubError):
|
904 | 951 | self.instance.create_pull(title='foo',base='master')
|
905 | 952 |
|
| 953 | +deftest_create_pull_from_issue(self): |
| 954 | +""" |
| 955 | + Verify that creating a pull request from issue requires authentication. |
| 956 | + """ |
| 957 | +withpytest.raises(GitHubError): |
| 958 | +self.instance.create_pull_from_issue( |
| 959 | +issue=1, |
| 960 | +title='foo', |
| 961 | +base='master' |
| 962 | + ) |
| 963 | + |
906 | 964 | deftest_hooks(self):
|
907 | 965 | """Show that a user must be authenticated to list hooks."""
|
908 | 966 | withpytest.raises(GitHubError):
|
|