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

Python models.Repository类代码示例

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

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



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

示例1: _test_get_file_exists

    def _test_get_file_exists(self, tool_name, revision, base_commit_id,
                              expected_revision, expected_found,
                              expected_http_called=True):
        def _http_get(service, url, *args, **kwargs):
            self.assertEqual(
                url,
                'https://bitbucket.org/api/1.0/repositories/'
                'myuser/myrepo/raw/%s/path'
                % expected_revision)

            if expected_found:
                return b'{}', {}
            else:
                error = HTTPError(url, 404, 'Not Found', {}, None)
                error.read = lambda: error.msg
                raise error

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account,
                                tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {
            'bitbucket_repo_name': 'myrepo',
        }

        account.data['password'] = encrypt_password('abc123')

        self.spy_on(service.client.http_get, call_fake=_http_get)

        result = service.get_file_exists(repository, 'path', revision,
                                         base_commit_id)
        self.assertEqual(service.client.http_get.called, expected_http_called)
        self.assertEqual(result, expected_found)
开发者ID:xiaogao6681,项目名称:reviewboard,代码行数:33,代码来源:test_bitbucket.py


示例2: _test_get_file_exists

    def _test_get_file_exists(self, tool_name, revision, base_commit_id,
                              expected_revision, expected_found,
                              expected_http_called=True):
        def _http_get(service, url, *args, **kwargs):
            self.assertEqual(
                url,
                'https://bitbucket.org/api/1.0/repositories/'
                'myuser/myrepo/raw/%s/path'
                % expected_revision)

            if expected_found:
                return '{}', {}
            else:
                raise HTTPError()

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account,
                                tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {
            'bitbucket_repo_name': 'myrepo',
        }

        service.authorize('myuser', 'abc123', None)

        self.spy_on(service._http_get, call_fake=_http_get)

        result = service.get_file_exists(repository, 'path', revision,
                                         base_commit_id)
        self.assertEqual(service._http_get.called, expected_http_called)
        self.assertEqual(result, expected_found)
开发者ID:harrifeng,项目名称:reviewboard,代码行数:31,代码来源:tests.py


示例3: test_check_repository_subversion

    def test_check_repository_subversion(self):
        """Testing Assembla.check_repository with Subversion"""
        try:
            account = self.create_hosting_account()
            service = account.service

            service.authorize('myuser', 'abc123', None)

            repository = Repository(path='https://svn.example.com/',
                                    hosting_account=account,
                                    tool=Tool.objects.get(name='Subversion'))
            scmtool = repository.get_scmtool()
            self.spy_on(scmtool.check_repository, call_original=False)

            service.check_repository(path='https://svn.example.com/',
                                     username='myusername',
                                     password='mypassword',
                                     scmtool_class=scmtool.__class__,
                                     local_site_name=None)

            self.assertTrue(scmtool.check_repository.called)
            self.assertNotIn('p4_host',
                             scmtool.check_repository.last_call.kwargs)
        except ImportError:
            raise nose.SkipTest
开发者ID:chipx86,项目名称:reviewboard,代码行数:25,代码来源:test_assembla.py


示例4: _test_get_file

    def _test_get_file(self, tool_name, revision, base_commit_id,
                       expected_revision):
        def _http_get(service, url, *args, **kwargs):
            self.assertEqual(
                url,
                'https://bitbucket.org/api/1.0/repositories/'
                'myuser/myrepo/raw/%s/path'
                % expected_revision)
            return b'My data', {}

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account,
                                tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {
            'bitbucket_repo_name': 'myrepo',
        }

        account.data['password'] = encrypt_password('abc123')

        self.spy_on(service.client.http_get, call_fake=_http_get)

        result = service.get_file(repository, 'path', revision,
                                  base_commit_id)
        self.assertTrue(service.client.http_get.called)
        self.assertEqual(result, 'My data')
开发者ID:xiaogao6681,项目名称:reviewboard,代码行数:26,代码来源:test_bitbucket.py


示例5: test_is_ssh_key_associated

    def test_is_ssh_key_associated(self):
        """Testing that GitHub associated SSH keys are correctly identified"""
        associated_key = 'good_key'
        unassociated_key = 'bad_key'
        keys = simplejson.dumps([
            {'key': 'neutral_key'},
            {'key': associated_key}
        ])

        def _http_get(self, *args, **kwargs):
            return keys, None

        self.service_class._http_get = _http_get
        self.service_class._format_public_key = lambda self, key: key

        account = self._get_hosting_account()
        account.data['authorization'] = {'token': 'abc123'}
        service = account.service

        repository = Repository(hosting_account=account)
        repository.extra_data = {
            'repository_plan': 'public',
            'github_public_repo_name': 'myrepo',
        }

        self.assertTrue(service.is_ssh_key_associated(repository,
                                                      associated_key))
        self.assertFalse(service.is_ssh_key_associated(repository,
                                                       unassociated_key))
        self.assertFalse(service.is_ssh_key_associated(repository, None))
开发者ID:B-Rich,项目名称:reviewboard,代码行数:30,代码来源:tests.py


示例6: test_check_repository_perforce

    def test_check_repository_perforce(self):
        """Testing Assembla.check_repository with Perforce"""
        try:
            account = self.create_hosting_account()
            service = account.service

            service.authorize('myuser', 'abc123', None)

            repository = Repository(hosting_account=account,
                                    tool=Tool.objects.get(name='Perforce'))
            scmtool = repository.get_scmtool()
            self.spy_on(scmtool.check_repository, call_original=False)

            service.check_repository(path='mypath',
                                     username='myusername',
                                     password='mypassword',
                                     scmtool_class=scmtool.__class__,
                                     local_site_name=None,
                                     assembla_project_id='myproject')

            self.assertTrue(scmtool.check_repository.called)
            self.assertIn('p4_host', scmtool.check_repository.last_call.kwargs)
            self.assertEqual(
                scmtool.check_repository.last_call.kwargs['p4_host'],
                'myproject')
        except ImportError:
            raise nose.SkipTest
开发者ID:chipx86,项目名称:reviewboard,代码行数:27,代码来源:test_assembla.py


示例7: test_get_branches

    def test_get_branches(self):
        """Testing GitHub get_branches implementation"""
        branches_api_response = simplejson.dumps(
            [
                {"ref": "refs/heads/master", "object": {"sha": "859d4e148ce3ce60bbda6622cdbe5c2c2f8d9817"}},
                {"ref": "refs/heads/release-1.7.x", "object": {"sha": "92463764015ef463b4b6d1a1825fee7aeec8cb15"}},
                {"ref": "refs/tags/release-1.7.11", "object": {"sha": "f5a35f1d8a8dcefb336a8e3211334f1f50ea7792"}},
            ]
        )

        def _http_get(self, *args, **kwargs):
            return branches_api_response, None

        self.service_class._http_get = _http_get

        account = self._get_hosting_account()
        account.data["authorization"] = {"token": "abc123"}

        repository = Repository(hosting_account=account)
        repository.extra_data = {"repository_plan": "public", "github_public_repo_name": "myrepo"}

        service = account.service
        branches = service.get_branches(repository)

        self.assertEqual(len(branches), 2)
        self.assertEqual(
            branches,
            [
                Branch("master", "859d4e148ce3ce60bbda6622cdbe5c2c2f8d9817", True),
                Branch("release-1.7.x", "92463764015ef463b4b6d1a1825fee7aeec8cb15", False),
            ],
        )
开发者ID:sieverssj,项目名称:reviewboard,代码行数:32,代码来源:tests.py


示例8: test_associate_ssh_key

    def test_associate_ssh_key(self):
        """Testing that GitHub SSH key association sends expected data"""
        http_post_data = {}

        def _http_post(self, *args, **kwargs):
            http_post_data['args'] = args
            http_post_data['kwargs'] = kwargs
            return None, None

        self.service_class._http_post = _http_post
        self.service_class._format_public_key = lambda self, key: key

        account = self._get_hosting_account()
        account.data['authorization'] = {'token': 'abc123'}

        repository = Repository(hosting_account=account)
        repository.extra_data = {
            'repository_plan': 'public',
            'github_public_repo_name': 'myrepo',
        }

        service = account.service
        service.associate_ssh_key(repository, 'mykey')
        req_body = simplejson.loads(http_post_data['kwargs']['body'])
        expected_title = ('Review Board (%s)'
                          % Site.objects.get_current().domain)

        self.assertEqual(http_post_data['args'][0],
                         'https://api.github.com/repos/myuser/myrepo/keys?'
                         'access_token=abc123')
        self.assertEqual(http_post_data['kwargs']['content_type'],
                         'application/json')
        self.assertEqual(req_body['title'], expected_title)
        self.assertEqual(req_body['key'], 'mykey')
开发者ID:B-Rich,项目名称:reviewboard,代码行数:34,代码来源:tests.py


示例9: _test_get_file_exists

    def _test_get_file_exists(
        self, tool_name, revision, base_commit_id, expected_revision, expected_found, expected_http_called=True
    ):
        def _http_get(service, url, *args, **kwargs):
            expected_url = "https://mydomain.beanstalkapp.com/api/" "repositories/myrepo/"

            if base_commit_id:
                expected_url += "node.json?path=/path&revision=%s&contents=0" % expected_revision
            else:
                expected_url += "blob?id=%s&name=path" % expected_revision

            self.assertEqual(url, expected_url)

            if expected_found:
                return "{}", {}
            else:
                raise HTTPError()

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account, tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {"beanstalk_account_domain": "mydomain", "beanstalk_repo_name": "myrepo"}

        service.authorize("myuser", "abc123", None)

        self.spy_on(service._http_get, call_fake=_http_get)

        result = service.get_file_exists(repository, "/path", revision, base_commit_id)
        self.assertTrue(service._http_get.called)
        self.assertEqual(result, expected_found)
开发者ID:sieverssj,项目名称:reviewboard,代码行数:30,代码来源:tests.py


示例10: test_associate_ssh_key

    def test_associate_ssh_key(self):
        """Testing that GitHub SSH key association sends expected data"""
        http_post_data = {}

        def _http_post(self, *args, **kwargs):
            http_post_data["args"] = args
            http_post_data["kwargs"] = kwargs
            return None, None

        self.service_class._http_post = _http_post
        self.service_class._format_public_key = lambda self, key: key

        account = self._get_hosting_account()
        account.data["authorization"] = {"token": "abc123"}

        repository = Repository(hosting_account=account)
        repository.extra_data = {"repository_plan": "public", "github_public_repo_name": "myrepo"}

        service = account.service
        service.associate_ssh_key(repository, "mykey")
        req_body = simplejson.loads(http_post_data["kwargs"]["body"])
        expected_title = "Review Board (%s)" % Site.objects.get_current().domain

        self.assertEqual(
            http_post_data["args"][0], "https://api.github.com/repos/myuser/myrepo/keys?" "access_token=abc123"
        )
        self.assertEqual(http_post_data["kwargs"]["content_type"], "application/json")
        self.assertEqual(req_body["title"], expected_title)
        self.assertEqual(req_body["key"], "mykey")
开发者ID:sieverssj,项目名称:reviewboard,代码行数:29,代码来源:tests.py


示例11: _test_get_file_exists

    def _test_get_file_exists(self, tool_name, expect_git_blob_url=False,
                              file_exists=True):
        def _http_get(service, url, *args, **kwargs):
            if expect_git_blob_url:
                self.assertEqual(
                    url,
                    'https://api3.codebasehq.com/myproj/myrepo/blob/123')
            else:
                self.assertEqual(
                    url,
                    'https://api3.codebasehq.com/myproj/myrepo/blob/123/'
                    'myfile')

            if file_exists:
                return b'{}', {}
            else:
                raise HTTPError(url, 404, '', {}, StringIO())

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account,
                                tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {
            'codebasehq_project_name': 'myproj',
            'codebasehq_repo_name': 'myrepo',
        }

        self._authorize(service)

        self.spy_on(service.client.http_get, call_fake=_http_get)

        result = service.get_file_exists(repository, 'myfile', '123')
        self.assertTrue(service.client.http_get.called)
        self.assertEqual(result, file_exists)
开发者ID:davidt,项目名称:reviewboard,代码行数:34,代码来源:test_codebasehq.py


示例12: setUp

    def setUp(self):
        super(GitTests, self).setUp()

        tool = Tool.objects.get(name='Git')

        self.local_repo_path = os.path.join(os.path.dirname(__file__),
                                            '..', 'testdata', 'git_repo')
        self.git_ssh_path = ('localhost:%s'
                             % self.local_repo_path.replace('\\', '/'))
        remote_repo_path = '[email protected]:reviewboard/reviewboard.git'
        remote_repo_raw_url = ('http://github.com/api/v2/yaml/blob/show/'
                               'reviewboard/reviewboard/<revision>')

        self.repository = Repository(name='Git test repo',
                                     path=self.local_repo_path,
                                     tool=tool)
        self.remote_repository = Repository(name='Remote Git test repo',
                                            path=remote_repo_path,
                                            raw_file_url=remote_repo_raw_url,
                                            tool=tool)

        try:
            self.tool = self.repository.get_scmtool()
            self.remote_tool = self.remote_repository.get_scmtool()
        except ImportError:
            raise nose.SkipTest('git binary not found')
开发者ID:chipx86,项目名称:reviewboard,代码行数:26,代码来源:test_git.py


示例13: testNewReviewRequest1

    def testNewReviewRequest1(self):
        """Testing new_review_request view (uploading diffs)"""
        self.client.login(username='grumpy', password='grumpy')

        response = self.client.get('/r/new/')
        self.assertEqual(response.status_code, 200)

        testdata_dir = os.path.join(
            os.path.dirname(os.path.dirname(__file__)),
            'scmtools', 'testdata')
        svn_repo_path = os.path.join(testdata_dir, 'svn_repo')

        repository = Repository(name='Subversion SVN',
                                path='file://' + svn_repo_path,
                                tool=Tool.objects.get(name='Subversion'))
        repository.save()

        diff_filename = os.path.join(testdata_dir, 'svn_makefile.diff')

        f = open(diff_filename, 'r')

        response = self.client.post('/r/new/', {
            'repository': repository.id,
            'diff_path': f,
            'basedir': '/trunk',
        })

        f.close()

        self.assertEqual(response.status_code, 302)

        r = ReviewRequest.objects.order_by('-time_added')[0]
        self.assertEqual(response['Location'],
                         'http://testserver%s' % r.get_absolute_url())
开发者ID:ChrisTrimble,项目名称:reviewboard,代码行数:34,代码来源:tests.py


示例14: _test_get_file

    def _test_get_file(self, tool_name, revision, base_commit_id,
                       expected_revision):
        def _http_get(service, url, *args, **kwargs):
            self.assertEqual(
                url,
                'https://mydomain.beanstalkapp.com/api/repositories/'
                'myrepo/blob?id=%s&name=path'
                % expected_revision)
            return 'My data', {}

        account = self._get_hosting_account()
        service = account.service
        repository = Repository(hosting_account=account,
                                tool=Tool.objects.get(name=tool_name))
        repository.extra_data = {
            'beanstalk_account_domain': 'mydomain',
            'beanstalk_repo_name': 'myrepo',
        }

        service.authorize('myuser', 'abc123', None)

        self.spy_on(service._http_get, call_fake=_http_get)

        result = service.get_file(repository, '/path', revision,
                                  base_commit_id)
        self.assertTrue(service._http_get.called)
        self.assertEqual(result, 'My data')
开发者ID:harrifeng,项目名称:reviewboard,代码行数:27,代码来源:tests.py


示例15: test_ticket_login_with_local_site

    def test_ticket_login_with_local_site(self):
        """Testing Perforce with ticket-based logins with Local Sites"""
        repo = Repository(
            name='Perforce.com',
            path='public.perforce.com:1666',
            tool=Tool.objects.get(name='Perforce'),
            username='samwise',
            password='bogus',
            local_site=LocalSite.objects.get(name='local-site-1'))
        repo.extra_data = {
            'use_ticket_auth': True,
        }

        client = repo.get_scmtool().client
        self.assertTrue(client.use_ticket_auth)

        self.spy_on(client.get_ticket_status, call_fake=lambda *args: {
            'user': 'samwise',
            'expiration_secs': 100000,
        })

        self.spy_on(client.login, call_original=False)

        with client.connect():
            self.assertFalse(client.login.called)
            self.assertEqual(client.p4.ticket_file,
                             os.path.join(settings.SITE_DATA_DIR, 'p4',
                                          'local-site-1', 'p4tickets'))
开发者ID:darmhoo,项目名称:reviewboard,代码行数:28,代码来源:test_perforce.py


示例16: test_get_branches

    def test_get_branches(self):
        """Testing GitLab get_branches implementation"""
        branches_api_response = json.dumps([
            {
                'name': 'master',
                'commit': {
                    'id': 'ed899a2f4b50b4370feeea94676502b42383c746'
                }
            },
            {
                'name': 'branch1',
                'commit': {
                    'id': '6104942438c14ec7bd21c6cd5bd995272b3faff6'
                }
            },
            {
                'name': 'branch2',
                'commit': {
                    'id': '21b3bcabcff2ab3dc3c9caa172f783aad602c0b0'
                }
            },
            {
                'branch-name': 'branch3',
                'commit': {
                    'id': 'd5a3ff139356ce33e37e73add446f16869741b50'
                }
            }
        ])

        def _http_get(self, *args, **kwargs):
            return branches_api_response, None

        account = self._get_hosting_account(use_url=True)
        account.data['private_token'] = encrypt_password('abc123')

        service = account.service

        repository = Repository(hosting_account=account)
        repository.extra_data = {'gitlab_project_id': 123456}

        self.spy_on(service.client.http_get, call_fake=_http_get)

        branches = service.get_branches(repository)

        self.assertTrue(service.client.http_get.called)
        self.assertEqual(len(branches), 3)
        self.assertEqual(
            branches,
            [
                Branch(id='master',
                       commit='ed899a2f4b50b4370feeea94676502b42383c746',
                       default=True),
                Branch(id='branch1',
                       commit='6104942438c14ec7bd21c6cd5bd995272b3faff6',
                       default=False),
                Branch(id='branch2',
                       commit='21b3bcabcff2ab3dc3c9caa172f783aad602c0b0',
                       default=False)
            ])
开发者ID:CharanKamal-CLI,项目名称:reviewboard,代码行数:59,代码来源:test_gitlab.py


示例17: testBadRoot

    def testBadRoot(self):
        """Testing a bad CVSROOT"""
        file = "test/testfile"
        rev = Revision("1.1")
        badrepo = Repository(name="CVS", path=self.cvs_repo_path + "2", tool=Tool.objects.get(name="CVS"))
        badtool = badrepo.get_scmtool()

        self.assertRaises(SCMError, lambda: badtool.get_file(file, rev))
开发者ID:Kamlani,项目名称:reviewboard,代码行数:8,代码来源:tests.py


示例18: test_get_commits

    def test_get_commits(self):
        """Testing GitHub get_commits implementation"""
        commits_api_response = simplejson.dumps(
            [
                {
                    "commit": {
                        "author": {"name": "Christian Hammond"},
                        "committer": {"date": "2013-06-25T23:31:22Z"},
                        "message": "Fixed the bug number for the blacktriangledown bug.",
                    },
                    "sha": "859d4e148ce3ce60bbda6622cdbe5c2c2f8d9817",
                    "parents": [{"sha": "92463764015ef463b4b6d1a1825fee7aeec8cb15"}],
                },
                {
                    "commit": {
                        "author": {"name": "Christian Hammond"},
                        "committer": {"date": "2013-06-25T23:30:59Z"},
                        "message": "Merge branch 'release-1.7.x'",
                    },
                    "sha": "92463764015ef463b4b6d1a1825fee7aeec8cb15",
                    "parents": [
                        {"sha": "f5a35f1d8a8dcefb336a8e3211334f1f50ea7792"},
                        {"sha": "6c5f3465da5ed03dca8128bb3dd03121bd2cddb2"},
                    ],
                },
                {
                    "commit": {
                        "author": {"name": "David Trowbridge"},
                        "committer": {"date": "2013-06-25T22:41:09Z"},
                        "message": "Add DIFF_PARSE_ERROR to the ValidateDiffResource.create error list.",
                    },
                    "sha": "f5a35f1d8a8dcefb336a8e3211334f1f50ea7792",
                    "parents": [],
                },
            ]
        )

        def _http_get(self, *args, **kwargs):
            return commits_api_response, None

        self.service_class._http_get = _http_get

        account = self._get_hosting_account()
        account.data["authorization"] = {"token": "abc123"}

        repository = Repository(hosting_account=account)
        repository.extra_data = {"repository_plan": "public", "github_public_repo_name": "myrepo"}

        service = account.service
        commits = service.get_commits(repository, "859d4e148ce3ce60bbda6622cdbe5c2c2f8d9817")

        self.assertEqual(len(commits), 3)
        self.assertEqual(commits[0].parent, commits[1].id)
        self.assertEqual(commits[1].parent, commits[2].id)
        self.assertEqual(commits[0].date, "2013-06-25T23:31:22Z")
        self.assertEqual(commits[1].id, "92463764015ef463b4b6d1a1825fee7aeec8cb15")
        self.assertEqual(commits[2].author_name, "David Trowbridge")
        self.assertEqual(commits[2].parent, "")
开发者ID:sieverssj,项目名称:reviewboard,代码行数:58,代码来源:tests.py


示例19: testPathWithoutPort

    def testPathWithoutPort(self):
        """Testing parsing a CVSROOT without a port"""
        repo = Repository(
            name="CVS", path="example.com:/cvsroot/test", username="anonymous", tool=Tool.objects.get(name="CVS")
        )
        tool = repo.get_scmtool()

        self.assertEqual(tool.repopath, "/cvsroot/test")
        self.assertEqual(tool.client.repository, ":pserver:[email protected]:/cvsroot/test")
开发者ID:Kamlani,项目名称:reviewboard,代码行数:9,代码来源:tests.py


示例20: add_repository

    def add_repository(self, name, url):
        """Add a repository to Review Board."""
        with wrap_env():
            self._setup_env()

            from reviewboard.scmtools.models import Repository, Tool
            tool = Tool.objects.get(name__exact='Mercurial')
            r = Repository(name=name, path=url, tool=tool)
            r.save()
            return r.id
开发者ID:simar7,项目名称:git-version-control-tools-clone,代码行数:10,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python urlresolvers.local_site_reverse函数代码示例发布时间:2022-05-26
下一篇:
Python forms.RepositoryForm类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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