コード例 #1
0
ファイル: cmds.py プロジェクト: GymWenFLL/tpp_libs
    def run(self,
            public_url=None,
            project='',
            product=None,
            branch_name='',
            branch_title='',
            branch_description='',
            author='',
            link_bug=None,
            dry_run=False):
        from bzrlib.plugins.launchpad.lp_registration import (
            BranchRegistrationRequest, BranchBugLinkRequest,
            DryRunLaunchpadService, LaunchpadService)
        if public_url is None:
            try:
                b = _mod_branch.Branch.open_containing('.')[0]
            except NotBranchError:
                raise BzrCommandError(gettext(
                            'register-branch requires a public '
                            'branch url - see bzr help register-branch.'))
            public_url = b.get_public_branch()
            if public_url is None:
                raise NoPublicBranch(b)
        if product is not None:
            project = product
            trace.note(gettext(
                '--product is deprecated; please use --project.'))


        rego = BranchRegistrationRequest(branch_url=public_url,
                                         branch_name=branch_name,
                                         branch_title=branch_title,
                                         branch_description=branch_description,
                                         product_name=project,
                                         author_email=author,
                                         )
        linko = BranchBugLinkRequest(branch_url=public_url,
                                     bug_id=link_bug)
        if not dry_run:
            service = LaunchpadService()
            # This gives back the xmlrpc url that can be used for future
            # operations on the branch.  It's not so useful to print to the
            # user since they can't do anything with it from a web browser; it
            # might be nice for the server to tell us about an html url as
            # well.
        else:
            # Run on service entirely in memory
            service = DryRunLaunchpadService()
        service.gather_user_credentials()
        rego.submit(service)
        if link_bug:
            linko.submit(service)
        self.outf.write('Branch registered.\n')
コード例 #2
0
ファイル: cmds.py プロジェクト: pombreda/dist-packages
    def run(self,
            public_url=None,
            project='',
            product=None,
            branch_name='',
            branch_title='',
            branch_description='',
            author='',
            link_bug=None,
            dry_run=False):
        from bzrlib.plugins.launchpad.lp_registration import (
            BranchRegistrationRequest, BranchBugLinkRequest,
            DryRunLaunchpadService, LaunchpadService)
        if public_url is None:
            try:
                b = _mod_branch.Branch.open_containing('.')[0]
            except NotBranchError:
                raise BzrCommandError(
                    gettext('register-branch requires a public '
                            'branch url - see bzr help register-branch.'))
            public_url = b.get_public_branch()
            if public_url is None:
                raise NoPublicBranch(b)
        if product is not None:
            project = product
            trace.note(
                gettext('--product is deprecated; please use --project.'))

        rego = BranchRegistrationRequest(
            branch_url=public_url,
            branch_name=branch_name,
            branch_title=branch_title,
            branch_description=branch_description,
            product_name=project,
            author_email=author,
        )
        linko = BranchBugLinkRequest(branch_url=public_url, bug_id=link_bug)
        if not dry_run:
            service = LaunchpadService()
            # This gives back the xmlrpc url that can be used for future
            # operations on the branch.  It's not so useful to print to the
            # user since they can't do anything with it from a web browser; it
            # might be nice for the server to tell us about an html url as
            # well.
        else:
            # Run on service entirely in memory
            service = DryRunLaunchpadService()
        service.gather_user_credentials()
        rego.submit(service)
        if link_bug:
            linko.submit(service)
        self.outf.write('Branch registered.\n')
コード例 #3
0
 def test_mock_server_registration_with_defaults(self):
     """Send registration to mock server"""
     test_case = self
     class MockRegistrationService(MockLaunchpadService):
         def send_request(self, method_name, method_params, authenticated):
             test_case.assertEquals(method_name, "register_branch")
             test_case.assertEquals(list(method_params),
                     ['http://server/branch', 'branch', '', '', '', ''])
             test_case.assertEquals(authenticated, True)
             return 'result'
     service = MockRegistrationService()
     rego = BranchRegistrationRequest('http://server/branch')
     result = rego.submit(service)
     self.assertEquals(result, 'result')
コード例 #4
0
 def test_mock_server_registration(self):
     """Send registration to mock server"""
     test_case = self
     class MockRegistrationService(MockLaunchpadService):
         def send_request(self, method_name, method_params, authenticated):
             test_case.assertEquals(method_name, "register_branch")
             test_case.assertEquals(list(method_params),
                     ['url', 'name', 'title', 'description', 'email', 'name'])
             test_case.assertEquals(authenticated, True)
             return 'result'
     service = MockRegistrationService()
     rego = BranchRegistrationRequest('url', 'name', 'title',
                     'description', 'email', 'name')
     result = rego.submit(service)
     self.assertEquals(result, 'result')
コード例 #5
0
 def test_onto_transport(self):
     """How the request is sent by transmitting across a mock Transport"""
     # use a real transport, but intercept at the http/xml layer
     transport = InstrumentedXMLRPCTransport(self, expect_auth=True)
     service = LaunchpadService(transport)
     service.registrant_email = '*****@*****.**'
     service.registrant_password = '******'
     rego = BranchRegistrationRequest('http://test-server.com/bzr/branch',
             'branch-id',
             'my test branch',
             'description',
             '*****@*****.**',
             'product')
     rego.submit(service)
     self.assertEquals(transport.connected_host, 'xmlrpc.launchpad.net')
     self.assertEquals(len(transport.sent_params), 6)
     self.assertEquals(transport.sent_params,
             ('http://test-server.com/bzr/branch',  # branch_url
              'branch-id',                          # branch_name
              'my test branch',                     # branch_title
              'description',
              '*****@*****.**',
              'product'))
     self.assertTrue(transport.got_request)