当前位置: 首页>>代码示例>>Python>>正文


Python expect.githuberror函数代码示例

本文整理汇总了Python中tests.utils.expect.githuberror函数的典型用法代码示例。如果您正苦于以下问题:Python githuberror函数的具体用法?Python githuberror怎么用?Python githuberror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了githuberror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update

    def test_update(self):
        self.response('repo_comment', 200)
        self.post(self.api)
        data = {
            'body': 'This is a comment body',
            'sha': 'fakesha', 'line': 1, 'position': 1,
            'path': 'github3/repos.py',
        }
        self.conf = {'data': data.copy()}
        self.conf['data']['commit_id'] = self.conf['data']['sha']
        del(self.conf['data']['sha'])

        with expect.githuberror():
            self.comment.update('foo', 'bar', 'bogus', 'jargon', 'files')

        self.login()
        expect(self.comment.update(None, 'f', 'o', 1, 1)).is_False()
        expect(self.comment.update('f', None, 'o', 1, 1)).is_False()
        expect(self.comment.update('f', 'o', 1, None, 1)).is_False()
        expect(self.comment.update('f', 'o', 0, 'o', 1)).is_False()
        expect(self.comment.update('f', 'o', 1, 'o', 0)).is_False()
        self.not_called()

        expect(self.comment.update(**data)).is_True()
        self.mock_assertions()
开发者ID:dahlia,项目名称:github3.py,代码行数:25,代码来源:test_repos.py

示例2: test_create_tag

    def test_create_tag(self):
        self.response('tag', 201)
        self.post(self.api + 'git/tags')
        data = {
            'tag': '0.3', 'message': 'Fake message', 'object': 'fakesha',
            'type': 'commit', 'tagger': {
                'name': 'Ian Cordasco', 'date': 'Not a UTC date',
                'email': '[email protected]'
            }
        }
        self.conf = {'data': data.copy()}
        data['obj_type'] = data['type']
        data['sha'] = data['object']
        del(data['type'], data['object'])

        with expect.githuberror():
            self.repo.create_tag(None, None, None, None, None)

        self.login()
        with patch.object(github3.repos.Repository, 'create_ref'):
            expect(self.repo.create_tag(None, None, None, None,
                                        None)).is_None()
            tag = self.repo.create_tag(**data)
            expect(tag).isinstance(github3.git.Tag)
            expect(repr(tag).startswith('<Tag')).is_True()
        self.mock_assertions()

        with patch.object(github3.repos.Repository, 'create_ref') as cr:
            self.repo.create_tag('tag', '', 'fakesha', '', '',
                                 lightweight=True)
            cr.assert_called_once_with('refs/tags/tag', 'fakesha')
开发者ID:dahlia,项目名称:github3.py,代码行数:31,代码来源:test_repos.py

示例3: test_boolean

    def test_boolean(self):
        r = requests.Response()
        r.status_code = 512
        r.raw = BytesIO('{}'.encode() if is_py3 else '{}')

        with expect.githuberror():
            self.g._boolean(r, 200, 404)
开发者ID:WheresWardy,项目名称:github3.py,代码行数:7,代码来源:test_models.py

示例4: test_create_issue

    def test_create_issue(self):
        self.request.return_value = generate_response('issue', 201)
        title = 'Construct _api attribute on our own'
        self.args = ('POST', self.api + 'issues')
        self.conf = {'data': {'title': title}}

        with expect.githuberror():
            self.repo.create_issue(title)

        self.login()
        expect(self.repo.create_issue(None)).is_None()
        expect(self.repo.create_issue(title)).isinstance(github3.issues.Issue)
        self.mock_assertions()

        body = 'Fake body'
        #self.conf['data'].update(body=body)
        expect(self.repo.create_issue(title, body)
               ).isinstance(github3.issues.Issue)
        self.mock_assertions()

        assignee, mile, labels = 'sigmavirus24', 1, ['bug', 'enhancement']
        #self.conf['data'].update({'assignee': assignee, 'milestone': mile,
        #                          'labels': labels})
        expect(self.repo.create_issue(title, body, assignee, mile, labels)
               ).isinstance(github3.issues.Issue)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:26,代码来源:test_repos.py

示例5: test_pubsubhubbub

    def test_pubsubhubbub(self):
        self.response('', 204)
        self.post('https://api.github.com/hub')
        body = [('hub.mode', 'subscribe'),
                ('hub.topic', 'https://github.com/foo/bar/events/push'),
                ('hub.callback', 'https://localhost/post')]
        self.conf = {}

        with expect.githuberror():
            self.g.pubsubhubbub('', '', '')

        self.login()
        expect(self.g.pubsubhubbub('', '', '')).is_False()
        self.not_called()

        expect(self.g.pubsubhubbub('foo', 'https://example.com', 'foo')
               ).is_False()
        self.not_called()

        d = dict([(k[4:], v) for k, v in body])
        expect(self.g.pubsubhubbub(**d)).is_True()
        _, kwargs = self.request.call_args
        expect('data').is_in(kwargs)
        expect(body) == kwargs['data']
        self.mock_assertions()

        d['secret'] = 'secret'
        body.append(('hub.secret', 'secret'))
        expect(self.g.pubsubhubbub(**d)).is_True()
        _, kwargs = self.request.call_args
        expect('data').is_in(kwargs)
        expect(body) == kwargs['data']
        self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:33,代码来源:test_github.py

示例6: test_create_repo

    def test_create_repo(self):
        self.response('repo', 201)
        self.post(self.api + '/repos')
        self.conf = {
            'data': {
                'name': 'repo',
                'description': 'desc',
                'homepage': '',
                'private': False,
                'has_issues': True,
                'has_wiki': True,
                'has_downloads': True,
                'auto_init': False,
                'team_id': 1,
                'gitignore_template': '',
            }
        }

        with expect.githuberror():
            self.org.create_repo(None)

        self.not_called()
        self.login()
        expect(self.org.create_repo('repo', 'desc', team_id=1)).isinstance(
            github3.repos.Repository)
        self.mock_assertions()
开发者ID:Lukasa,项目名称:github3.py,代码行数:26,代码来源:test_orgs.py

示例7: test_edit

    def test_edit(self):
        self.response('hook', 200)
        self.patch(self.api)
        data = {
            'name': 'hookname',
            'config': {'push': 'http://example.com'},
            'events': ['push'],
            'add_events': ['fake_ev'],
            'rm_events': ['fake_ev'],
            'active': True,
        }
        self.conf = {'data': data.copy()}
        self.conf['data']['remove_events'] = data['rm_events']
        del(self.conf['data']['rm_events'])

        with expect.githuberror():
            self.hook.edit(**data)

        self.login()
        expect(self.hook.edit(None, None, None)).is_False()
        expect(self.hook.edit('True', None, None)).is_False()
        expect(self.hook.edit(None, 'True', None)).is_False()
        expect(self.hook.edit(None, None, {})).is_False()
        self.not_called()

        expect(self.hook.edit(**data)).is_True()
        self.mock_assertions()
开发者ID:dahlia,项目名称:github3.py,代码行数:27,代码来源:test_repos.py

示例8: test_update

    def test_update(self):
        self.response('authorization', 200)
        self.post(self.api)
        data = {
            'scopes': ['user']
        }
        self.conf = {'data': data}

        with expect.githuberror():
            self.auth.update()

        def sub_test():
            expect(self.auth.update(**data)).is_True()
            self.mock_assertions()

        self.login()
        expect(self.auth.update()).is_False()
        self.not_called()

        sub_test()

        del(data['scopes'])
        data['add_scopes'] = ['repo']
        sub_test()

        del(data['add_scopes'])
        data['rm_scopes'] = ['user']
        self.conf['data'] = {'remove_scopes': ['user']}
        sub_test()
        self.conf['data'] = data

        del(data['rm_scopes'])
        data['note'] = 'GitHub API'
        data['note_url'] = 'http://example.com'
        sub_test()
开发者ID:Lukasa,项目名称:github3.py,代码行数:35,代码来源:test_auths.py

示例9: test_delete_email_address

    def test_delete_email_address(self):
        with expect.githuberror():
            self.user.delete_email_address('foo')

        self.not_called()
        self.login()
        with patch.object(github3.users.User, 'delete_email_addresses') as p:
            self.user.delete_email_address('foo')
            p.assert_called_once_with(['foo'])
开发者ID:dialelo,项目名称:github3.py,代码行数:9,代码来源:test_users.py

示例10: test_reopen

    def test_reopen(self):
        with expect.githuberror():
            self.pull.reopen()

        self.login()
        with patch.object(github3.pulls.PullRequest, 'update') as up:
            self.pull.reopen()
            up.assert_called_once_with(
                self.pull.title, self.pull.body, 'open')
开发者ID:Lukasa,项目名称:github3.py,代码行数:9,代码来源:test_pulls.py

示例11: test_star

    def test_star(self):
        self.response('', 204)
        self.put(self.api)

        with expect.githuberror():
            self.gist.star()

        self.not_called()
        self.login()
        expect(self.gist.star()).is_True()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:10,代码来源:test_gists.py

示例12: test_delete

    def test_delete(self):
        self.response('', 204)
        self.delete(self.api)

        with expect.githuberror():
            self.l.delete()

        self.not_called()
        self.login()
        expect(self.l.delete()).is_True()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:10,代码来源:test_issues.py

示例13: test_remove_all_labels

    def test_remove_all_labels(self):
        with expect.githuberror():
            self.i.remove_all_labels()

        self.login()

        with patch.object(github3.issues.Issue, 'replace_labels') as rl:
            rl.return_value = []
            expect(self.i.remove_all_labels()) == []
            rl.assert_called_once_with([])
开发者ID:WheresWardy,项目名称:github3.py,代码行数:10,代码来源:test_issues.py

示例14: test_remove_label

    def test_remove_label(self):
        self.response('', 204)
        self.delete(self.api + '/labels/name')

        with expect.githuberror():
            self.i.remove_label('name')

        self.not_called()
        self.login()
        expect(self.i.remove_label('name')).is_True()
        self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:11,代码来源:test_issues.py

示例15: test_iter_teams

    def test_iter_teams(self):
        self.response('team', _iter=True)
        self.get(self.api + '/teams')

        with expect.githuberror():
            self.org.iter_teams()

        self.not_called()
        self.login()
        expect(next(self.org.iter_teams())).isinstance(github3.orgs.Team)
        self.mock_assertions()
开发者ID:Lukasa,项目名称:github3.py,代码行数:11,代码来源:test_orgs.py


注:本文中的tests.utils.expect.githuberror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。