示例#1
0
class TestSubversionArgs(TestCase):
    def setUp(self):
        patcher = patch('pip._internal.vcs.versioncontrol.call_subprocess')
        self.addCleanup(patcher.stop)
        self.call_subprocess_mock = patcher.start()

        # Test Data.
        self.url = 'svn+http://username:[email protected]/'
        # use_interactive is set to False to test that remote call options are
        # properly added.
        self.svn = Subversion(use_interactive=False)
        self.rev_options = RevOptions(Subversion)
        self.dest = '/tmp/test'

    def assert_call_args(self, args):
        assert self.call_subprocess_mock.call_args[0][0] == args

    def test_obtain(self):
        self.svn.obtain(self.dest, self.url)
        self.assert_call_args(
            ['svn', 'checkout', '-q', '--non-interactive', '--username',
             'username', '--password', 'password',
             'http://svn.example.com/', '/tmp/test'])

    def test_export(self):
        self.svn.export(self.dest, self.url)
        self.assert_call_args(
            ['svn', 'export', '--non-interactive', '--username', 'username',
             '--password', 'password', 'http://svn.example.com/',
             '/tmp/test'])

    def test_fetch_new(self):
        self.svn.fetch_new(self.dest, self.url, self.rev_options)
        self.assert_call_args(
            ['svn', 'checkout', '-q', '--non-interactive',
             'svn+http://username:[email protected]/',
             '/tmp/test'])

    def test_fetch_new_revision(self):
        rev_options = RevOptions(Subversion, '123')
        self.svn.fetch_new(self.dest, self.url, rev_options)
        self.assert_call_args(
            ['svn', 'checkout', '-q', '--non-interactive',
             '-r', '123',
             'svn+http://username:[email protected]/',
             '/tmp/test'])

    def test_switch(self):
        self.svn.switch(self.dest, self.url, self.rev_options)
        self.assert_call_args(
            ['svn', 'switch', '--non-interactive',
             'svn+http://username:[email protected]/',
             '/tmp/test'])

    def test_update(self):
        self.svn.update(self.dest, self.url, self.rev_options)
        self.assert_call_args(
            ['svn', 'update', '--non-interactive', '/tmp/test'])
示例#2
0
def test_export_should_recognize_auth_info_url(call_subprocess_mock, script):
    url = 'svn+http://username:[email protected]/'
    svn = Subversion()
    svn.export(script.scratch_path / 'test', url=url)
    assert call_subprocess_mock.call_args[0][0] == [
        svn.name, 'export', '--username', 'username', '--password',
        'password', 'http://svn.example.com/',
        script.scratch_path / 'test',
    ]