本文整理汇总了Python中tests.utils.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reject
def test_reject(self):
class Issue(object):
def __init__(self, dictionary):
self.__dict__ = dictionary
def _get_issue(issue_id):
return self.client.github.issues.show(self.config["github"]["repo"], issue_id)
test_pr_id = 1
reject_message = u"Merge failed"
# TODO(LB): temporary -- repoen the pull request for this test
# Remove this line once github mocking is in place
self.expect(Issue(utils.load(utils.testdata("issue_open.json"))["issue"]))
self.client.github.issues.reopen(self.config["github"]["repo"], test_pr_id)
# verify the issue is open
issue = _get_issue(test_pr_id)
self.assertEqual(u"open", issue.state)
# TODO(LB): need to mock up github here as well; see test_comment()
client = StubbedGithub(config=self.config, conn_class=FakeGithub)
client.config.github_core_team = "test team 1"
pull_request = client.pull_requests.values()[0]
self.expect(Issue(utils.load(utils.testdata("issue_closed.json"))["issue"]))
rejected_issue = pull_request.close(reject_message)
self.assertEqual(u"closed", rejected_issue.state)
示例2: test_comment
def test_comment(self):
"""
Adds a comment to a test issue and verifies the comment is added.
TODO(LB): need to change the test setup so we're mocking the github
stuff for this (or else the tests run as slow as Chris's Mom).
"""
class Comment(object):
def __init__(self, dictionary):
self.__dict__ = dictionary
client = StubbedGithub(config=self.config, conn_class=FakeGithub)
client.config["github"]["core_team"] = "test team 1"
pull_request = client.pull_requests.values()[0]
test_issue_id = 12345
comment_text = u"test comment text"
# add the comment
self.expect(utils.load(utils.testdata("comment.json")))
comment_result = pull_request.comment(comment_text)
# now verify the comment was added
self.expect([Comment(x) for x in utils.load(utils.testdata("comments.json"))["comments"]])
comments = self.client.github.issues.comments(self.config["github"]["repo"], test_issue_id)
# filter the comments list by id
comment = [x for x in comments if x.id == comment_result["id"]]
# should only be one comment here
self.assertTrue(len(comment) == 1)
comment = comment[0]
self.assertEqual(comment_text, comment.body)
示例3: test_create_a_new_pull_request
def test_create_a_new_pull_request(self):
pr_str = utils.load(utils.testdata('new_pull_request.json'))
pr = pull_request.PullRequest(pr_str, self.pr_path)
self.assertNothingRaised(pr.save,)
self.assertTrue(os.path.exists(os.path.join(self.pr_path, "2", "pull.js")))
pr2 = pull_request.PullRequest.load(os.path.join(self.pr_path, "2"))
self.assertEqual(pr._pull_request, pr2._pull_request)
示例4: test_delete_key
def test_delete_key(self):
self.request.return_value = generate_response(None, 204)
self.login()
with patch.object(github3.github.GitHub, 'key') as key:
key.return_value = github3.users.Key(load('key'), self.g)
assert self.g.delete_key(10) is True
assert self.request.called is True
示例5: test_issue_137
def test_issue_137(self):
"""
GitHub sometimes returns `pull` as part of of the `html_url` for Issue
requests.
"""
i = Issue(load('issue_137'))
self.assertEqual(
i.html_url,
"https://github.com/sigmavirus24/github3.py/pull/1")
self.assertEqual(i.repository, ("sigmavirus24", "github3.py"))
示例6: test_iter_issue_comments
def test_iter_issue_comments(self):
pull = github3.pulls.PullRequest(load('pull19'))
self.response('pull19_comment', _iter=True)
self.get(pull.links['comments'])
c = next(pull.iter_issue_comments())
assert isinstance(c, github3.issues.comment.IssueComment)
self.mock_assertions()
assert repr(c).startswith('<Issue Comment')
示例7: test_issue
def test_issue(self):
self.response('issue', 200)
self.get('https://api.github.com/repos/sigmavirus24/github3.py/'
'issues/1')
assert self.g.issue(None, None, 0) is None
with patch.object(github3.github.GitHub, 'repository') as repo:
repo.return_value = github3.repos.Repository(load('repo'))
i = self.g.issue('user', 'repo', 1)
expect(i).isinstance(github3.issues.Issue)
self.mock_assertions()
示例8: test_iter_repo_issues
def test_iter_repo_issues(self):
self.response('issue', _iter=True)
self.get('https://api.github.com/repos/sigmavirus24/github3.py/'
'issues')
with patch.object(github3.GitHub, 'repository') as repo:
repo.return_value = github3.repos.Repository(load('repo'),
self.g)
i = next(self.g.iter_repo_issues('sigmavirus24', 'github3.py'))
expect(i).isinstance(github3.issues.Issue)
self.mock_assertions()
示例9: test_update_user
def test_update_user(self):
self.login()
args = ('Ian Cordasco', '[email protected]', 'www.blog.com', 'company',
'loc', True, 'bio')
with patch.object(github3.github.GitHub, 'user') as user:
with patch.object(github3.users.User, 'update') as upd:
user.return_value = github3.users.User(load('user'), self.g)
upd.return_value = True
expect(self.g.update_user(*args)).is_True()
expect(user.called).is_True()
expect(upd.called).is_True()
upd.assert_called_with(*args)
示例10: test_pull_request
def test_pull_request(self):
self.response('pull')
self.get('https://api.github.com/repos/sigmavirus24/'
'github3.py/pulls/18')
pr = None
with patch.object(github3.github.GitHub, 'repository') as repo:
repo.return_value = github3.repos.Repository(load('repo'))
pr = self.g.pull_request('sigmavirus24', 'github3.py', 18)
expect(pr).isinstance(github3.pulls.PullRequest)
self.mock_assertions()
示例11: test_iter_starred
def test_iter_starred(self):
self.response('repo', _iter=True)
self.get('https://api.github.com/user/starred')
self.conf.update(params={})
self.login()
expect(next(self.g.iter_starred())).isinstance(
github3.repos.Repository)
self.mock_assertions()
with patch.object(github3.github.GitHub, 'user') as user:
user.return_value = github3.users.User(load('user'))
self.get('https://api.github.com/users/sigmavirus24/starred')
expect(next(self.g.iter_starred('sigmavirus24'))).isinstance(
github3.repos.Repository)
self.mock_assertions()
示例12: test_iter_subscriptions
def test_iter_subscriptions(self):
self.response('repo', _iter=True)
self.get('https://api.github.com/user/subscriptions')
self.conf.update(params={'per_page': 100})
self.login()
assert isinstance(next(self.g.iter_subscriptions()),
github3.repos.Repository)
self.mock_assertions()
with patch.object(github3.github.GitHub, 'user') as user:
user.return_value = github3.users.User(load('user'))
self.get('https://api.github.com/users/sigmavirus24/'
'subscriptions')
assert isinstance(next(self.g.iter_subscriptions('sigmavirus24')),
github3.repos.Repository)
self.mock_assertions()
示例13: test_create_issue
def test_create_issue(self):
self.response('issue', 201)
self.login()
i = self.g.create_issue(None, None, None)
assert i is None
assert self.request.called is False
i = self.g.create_issue('user', 'repo', '')
assert i is None
assert self.request.called is False
with patch.object(github3.GitHub, 'repository') as repo:
repo.return_value = github3.repos.Repository(
load('repo'), self.g)
i = self.g.create_issue('user', 'repo', 'Title')
expect(i).isinstance(github3.issues.Issue)
assert self.request.called is True
示例14: test_iter_subscriptions
def test_iter_subscriptions(self):
self.request.return_value = generate_response('repo', _iter=True)
self.args = ('GET', 'https://api.github.com/user/subscriptions')
self.conf.update(params=None)
self.login()
expect(next(self.g.iter_subscriptions())).isinstance(
github3.repos.Repository)
self.mock_assertions()
with patch.object(github3.github.GitHub, 'user') as user:
user.return_value = github3.users.User(load('user'))
self.args = ('GET',
'https://api.github.com/users/sigmavirus24/'
'subscriptions'
)
expect(next(self.g.iter_subscriptions('sigmavirus24'))).isinstance(
github3.repos.Repository)
self.mock_assertions()
示例15: test_update_label
def test_update_label(self):
self.response('label')
self.patch(self.api + 'labels/Bug')
self.conf = {'data': {'name': 'big_bug', 'color': 'fafafa'}}
self.assertRaises(github3.GitHubError, self.repo.update_label, 'foo', 'bar')
self.not_called()
self.login()
with patch.object(repos.Repository, 'label') as l:
l.return_value = None
assert self.repo.update_label('foo', 'bar') is False
self.not_called()
with patch.object(repos.Repository, 'label') as l:
l.return_value = github3.issues.label.Label(load('label'), self.g)
assert self.repo.update_label('big_bug', 'fafafa')
self.mock_assertions()