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'])
def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script): url = 'svn+http://username:[email protected]/' svn = Subversion() svn.obtain(script.scratch_path / 'test', url=url) assert call_subprocess_mock.call_args[0][0] == [ svn.name, 'checkout', '-q', '--username', 'username', '--password', 'password', 'http://svn.example.com/', script.scratch_path / 'test', ]
class TestSubversionArgs(TestCase): def setUp(self) -> None: patcher = mock.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: CommandArgs) -> None: assert self.call_subprocess_mock.call_args[0][0] == args def test_obtain(self) -> None: self.svn.obtain(self.dest, hide_url(self.url), verbosity=0) self.assert_call_args([ "svn", "checkout", "--quiet", "--non-interactive", "--username", "username", "--password", hide_value("password"), hide_url("http://svn.example.com/"), "/tmp/test", ]) def test_fetch_new(self) -> None: self.svn.fetch_new(self.dest, hide_url(self.url), self.rev_options, verbosity=0) self.assert_call_args([ "svn", "checkout", "--quiet", "--non-interactive", hide_url("svn+http://username:[email protected]/"), "/tmp/test", ]) def test_fetch_new_revision(self) -> None: rev_options = RevOptions(Subversion, "123") self.svn.fetch_new(self.dest, hide_url(self.url), rev_options, verbosity=0) self.assert_call_args([ "svn", "checkout", "--quiet", "--non-interactive", "-r", "123", hide_url("svn+http://username:[email protected]/"), "/tmp/test", ]) def test_switch(self) -> None: self.svn.switch(self.dest, hide_url(self.url), self.rev_options) self.assert_call_args([ "svn", "switch", "--non-interactive", hide_url("svn+http://username:[email protected]/"), "/tmp/test", ]) def test_update(self) -> None: self.svn.update(self.dest, hide_url(self.url), self.rev_options) self.assert_call_args([ "svn", "update", "--non-interactive", "/tmp/test", ])