• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.generate_response函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_archive

    def test_archive(self):
        headers = {'content-disposition': 'filename=foo'}
        self.request.return_value = generate_response('archive', 200,
                                                      **headers)
        self.args = ('GET', self.api + 'tarball/master')
        self.conf.update({'stream': True})

        expect(self.repo.archive(None)).is_False()

        expect(os.path.isfile('foo')).is_False()
        expect(self.repo.archive('tarball')).is_True()
        expect(os.path.isfile('foo')).is_True()
        os.unlink('foo')
        self.mock_assertions()

        self.request.return_value.raw.seek(0)
        self.request.return_value._content_consumed = False

        expect(os.path.isfile('path_to_file')).is_False()
        expect(self.repo.archive('tarball', 'path_to_file')).is_True()
        expect(os.path.isfile('path_to_file')).is_True()
        os.unlink('path_to_file')

        self.request.return_value.raw.seek(0)
        self.request.return_value._content_consumed = False

        self.args = ('GET', self.api + 'zipball/randomref')
        expect(self.repo.archive('zipball', ref='randomref')).is_True()
        os.unlink('foo')
开发者ID:palfrey,项目名称:github3.py,代码行数:29,代码来源:test_repos.py


示例2: test_blob

    def test_blob(self):
        self.request.return_value = generate_response('blob')
        sha = '3ceb856e2f14e9669fed6384e58c9a1590a2314f'
        self.args = ('GET', self.api + 'git/blobs/' + sha)

        expect(self.repo.blob(sha)).isinstance(github3.git.Blob)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:7,代码来源:test_repos.py


示例3: test_contents

    def test_contents(self):
        self.request.return_value = generate_response('contents')
        filename = 'setup.py'
        self.args = ('GET', self.api + 'contents/' + filename)

        expect(self.repo.contents(filename)).isinstance(github3.repos.Contents)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:7,代码来源:test_repos.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_commit

    def test_commit(self):
        self.request.return_value = generate_response('commit')
        sha = '76dcc6cb4b9860034be81b7e58adc286a115aa97'
        self.args = ('GET', self.api + 'commits/' + sha)

        expect(self.repo.commit(sha)).isinstance(github3.repos.RepoCommit)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:7,代码来源:test_repos.py


示例6: test_iter_events

    def test_iter_events(self):
        self.request.return_value = generate_response('event', _iter=True)
        self.args = ('GET', 'https://api.github.com/events')
        self.conf.update(params=None)

        event = next(self.g.iter_events())
        expect(event).isinstance(github3.events.Event)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:8,代码来源:test_github.py


示例7: test_commit_comment

    def test_commit_comment(self):
        self.request.return_value = generate_response('commit_comment')
        comment_id = 1380832
        self.args = ('GET', self.api + 'comments/{0}'.format(comment_id))

        expect(self.repo.commit_comment(comment_id)
               ).isinstance(github3.repos.RepoComment)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:8,代码来源:test_repos.py


示例8: test_iter_all_users

    def test_iter_all_users(self):
        self.request.return_value = generate_response('user', _iter=True)
        self.args = ('GET', 'https://api.github.com/users')
        self.conf.update(params=None)

        repo = next(self.g.iter_all_users())
        expect(repo).isinstance(github3.users.User)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:8,代码来源:test_github.py


示例9: test_gitignore_template

    def test_gitignore_template(self):
        self.request.return_value = generate_response('template')
        self.args = ('GET',
                     'https://api.github.com/gitignore/templates/Python')

        template = self.g.gitignore_template('Python')
        expect(template.startswith('*.py[cod]')).is_True()
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:8,代码来源:test_github.py


示例10: test_search_users

 def test_search_users(self):
     self.request.return_value = generate_response('legacy_user')
     self.args = ('get',
                  'https://api.github.com/{0}/{1}/{2}/{3}'.format(
                  'legacy', 'user', 'search', 'sigmavirus24')
                  )
     users = self.g.search_users('sigmavirus24')
     expect(users[0]).isinstance(github3.legacy.LegacyUser)
     self.mock_assertions()
开发者ID:lyddonb,项目名称:github3.py,代码行数:9,代码来源:test_github.py


示例11: test_search_email

 def test_search_email(self):
     self.request.return_value = generate_response('legacy_email')
     self.args = ('GET',
                  'https://api.github.com/{0}/{1}/{2}/{3}'.format(
                  'legacy', 'user', 'email', '[email protected]')
                  )
     user = self.g.search_email('[email protected]')
     expect(user).isinstance(github3.legacy.LegacyUser)
     self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:9,代码来源:test_github.py


示例12: 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
开发者ID:palfrey,项目名称:github3.py,代码行数:9,代码来源:test_github.py


示例13: test_compare_commits

    def test_compare_commits(self):
        self.request.return_value = generate_response('comparison')
        base = 'a811e1a270f65eecb65755eca38d888cbefcb0a7'
        head = '76dcc6cb4b9860034be81b7e58adc286a115aa97'
        self.args = ('GET', self.api + 'compare/{0}...{1}'.format(base, head))

        expect(self.repo.compare_commits(base, head)
               ).isinstance(github3.repos.Comparison)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:9,代码来源:test_repos.py


示例14: test_authorize

    def test_authorize(self):
        self.request.return_value = generate_response('authorization', 201)
        scopes = ['scope1', 'scope2']

        self.g.authorize(None, None, scopes)
        assert self.request.called is False

        a = self.g.authorize('user', 'password', scopes)
        expect(a).isinstance(github3.auths.Authorization)
        assert self.request.called is True
开发者ID:palfrey,项目名称:github3.py,代码行数:10,代码来源:test_github.py


示例15: test_repository

    def test_repository(self):
        self.request.return_value = generate_response('repo')
        repo = self.g.repository(None, None)
        expect(repo).is_None()
        expect(self.request.called).is_False()

        self.args = ('GET',
                     'https://api.github.com/repos/sigmavirus24/github3.py')
        repo = self.g.repository('sigmavirus24', 'github3.py')
        expect(repo).isinstance(github3.repos.Repository)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:11,代码来源:test_github.py


示例16: test_user

    def test_user(self):
        self.request.return_value = generate_response('user')
        self.args = ('GET', 'https://api.github.com/users/sigmavirus24')

        expect(self.g.user('sigmavirus24')).isinstance(github3.users.User)
        self.mock_assertions()

        self.args = ('GET', 'https://api.github.com/user')
        self.login()
        expect(self.g.user()).isinstance(github3.users.User)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:11,代码来源:test_github.py


示例17: test_utf8_user

    def test_utf8_user(self):
        self.request.return_value = generate_response('utf8_user')
        self.args = ('GET', 'https://api.github.com/users/alejandrogomez')

        u = self.g.user('alejandrogomez')

        try:
            repr(u)
        except UnicodeEncodeError:
            self.fail('Regression caught. See PR #52. Names must be utf-8'
                      ' encoded')
开发者ID:palfrey,项目名称:github3.py,代码行数:11,代码来源:test_github.py


示例18: test_iter_keys

    def test_iter_keys(self):
        self.request.return_value = generate_response('key', _iter=True)
        self.args = ('GET', 'https://api.github.com/user/keys')
        self.conf.update(params=None)

        with expect.githuberror():
            self.g.iter_keys()

        self.login()
        expect(next(self.g.iter_keys())).isinstance(github3.users.Key)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:11,代码来源:test_github.py


示例19: test_authorization

    def test_authorization(self):
        self.request.return_value = generate_response('authorization')
        self.args = ('GET', 'https://api.github.com/authorizations/10')
        with expect.githuberror():
            self.g.authorization(10)
        assert self.request.called is False

        self.login()
        a = self.g.authorization(10)
        expect(a).isinstance(github3.auths.Authorization)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:11,代码来源:test_github.py


示例20: test_iter_orgs

    def test_iter_orgs(self):
        self.request.return_value = generate_response('org', _iter=True)
        self.args = ('GET', 'https://api.github.com/users/login/orgs')

        expect(next(self.g.iter_orgs('login'))).isinstance(
            github3.orgs.Organization)
        self.mock_assertions()

        self.args = ('GET', 'https://api.github.com/user/orgs')
        self.login()
        expect(next(self.g.iter_orgs())).isinstance(github3.orgs.Organization)
        self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:12,代码来源:test_github.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.generate_validator_from_schema函数代码示例发布时间:2022-05-27
下一篇:
Python utils.expect函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap