Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf99f5e

Browse files
Created unit tests for repository.create_pull_from_issue
1 parent01cb702 commitdf99f5e

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

‎tests/unit/test_repos_repo.py

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
fromgithub3importGitHubError
66
fromgithub3.nullimportNullObject
77
fromgithub3.repos.repoimportRepository
8+
fromgithub3.modelsimportGitHubCore
89

910
from .importhelper
1011

@@ -248,19 +249,65 @@ def test_create_milestone_accepted_state(self):
248249
}
249250
)
250251

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):
252261
"""Verify the request for creating a pull request."""
253262
data= {
254263
'title':'foo',
255264
'base':'master',
256265
'head':'feature_branch'
257266
}
258-
self.instance.create_pull(**data)
267+
self.instance._create_pull(data)
259268
self.post_called_with(
260269
url_for('pulls'),
261270
data=data
262271
)
263272

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+
264311
deftest_create_ref(self):
265312
"""Verify the request to create a reference."""
266313
self.instance.create_ref('refs/heads/foo','my-fake-sha')
@@ -903,6 +950,17 @@ def test_create_pull(self):
903950
withpytest.raises(GitHubError):
904951
self.instance.create_pull(title='foo',base='master')
905952

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+
906964
deftest_hooks(self):
907965
"""Show that a user must be authenticated to list hooks."""
908966
withpytest.raises(GitHubError):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp