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


Python utils.generate_response函数代码示例

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


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


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