/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/plugins/launchpad/test_register.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import base64
18
 
from StringIO import StringIO
19
18
import urlparse
20
19
import xmlrpclib
21
20
 
22
 
from bzrlib import (
 
21
from ... import (
23
22
    config,
24
23
    tests,
25
24
    ui,
26
25
    )
27
 
from bzrlib.tests import TestCaseWithTransport
 
26
from ...sixish import (
 
27
    BytesIO,
 
28
    )
 
29
from ...tests import TestCaseWithTransport
28
30
 
29
31
# local import
30
 
from bzrlib.plugins.launchpad.lp_registration import (
 
32
from .lp_registration import (
31
33
        BaseRequest,
32
34
        BranchBugLinkRequest,
33
35
        BranchRegistrationRequest,
83
85
 
84
86
    def getfile(self):
85
87
        """Return a fake file containing the response content."""
86
 
        return StringIO('''\
 
88
        return BytesIO(b'''\
87
89
<?xml version="1.0" ?>
88
90
<methodResponse>
89
91
    <params>
132
134
        pass
133
135
 
134
136
    def send_user_agent(self, conn):
135
 
        # TODO: send special user agent string, including bzrlib version
 
137
        # TODO: send special user agent string, including breezy version
136
138
        # number
137
139
        pass
138
140
 
158
160
    def setUp(self):
159
161
        super(TestBranchRegistration, self).setUp()
160
162
        # make sure we have a reproducible standard environment
161
 
        self.overrideEnv('BZR_LP_XMLRPC_URL', None)
 
163
        self.overrideEnv('BRZ_LP_XMLRPC_URL', None)
162
164
 
163
165
    def test_register_help(self):
164
166
        """register-branch accepts --help"""
170
172
        self.make_repository('.')
171
173
        self.run_bzr_error(
172
174
            ['register-branch requires a public branch url - '
173
 
             'see bzr help register-branch'],
 
175
             'see brz help register-branch'],
174
176
            'register-branch')
175
177
 
176
178
    def test_register_no_url_in_published_branch_no_error(self):
317
319
    def setUp(self):
318
320
        super(TestGatherUserCredentials, self).setUp()
319
321
        # make sure we have a reproducible standard environment
320
 
        self.overrideEnv('BZR_LP_XMLRPC_URL', None)
 
322
        self.overrideEnv('BRZ_LP_XMLRPC_URL', None)
321
323
 
322
324
    def test_gather_user_credentials_has_password(self):
323
325
        service = LaunchpadService()
356
358
        g_conf = config.GlobalStack()
357
359
        g_conf.set('email', 'Test User <test@user.com>')
358
360
        g_conf.store.save()
359
 
        stdout = tests.StringIOWrapper()
360
 
        stderr = tests.StringIOWrapper()
361
 
        ui.ui_factory = tests.TestUIFactory(stdin='userpass\n',
362
 
                                            stdout=stdout, stderr=stderr)
 
361
        ui.ui_factory = tests.TestUIFactory(stdin=u'userpass\n')
363
362
        self.assertIs(None, service.registrant_password)
364
363
        service.gather_user_credentials()
365
364
        self.assertEqual('test@user.com', service.registrant_email)
366
365
        self.assertEqual('userpass', service.registrant_password)
367
 
        self.assertEqual('', stdout.getvalue())
368
 
        self.assertContainsRe(stderr.getvalue(),
 
366
        self.assertEqual('', ui.ui_factory.stdout.getvalue())
 
367
        self.assertContainsRe(ui.ui_factory.stderr.getvalue(),
369
368
                             'launchpad.net password for test@user\\.com')
370
369