def test_pull_failure(self): self.mock_run.side_effect = subprocess.CalledProcessError(1, []) svn = sources.Subversion("svn://my-source", "source_dir") raised = self.assertRaises(sources.errors.SnapcraftPullError, svn.pull) self.assertThat( raised.command, Equals("svn checkout svn://my-source source_dir") ) self.assertThat(raised.exit_code, Equals(1))
def test_svn_details_commit(self): svn = sources.Subversion(self.repo_tree, self.source_dir, silent=True) svn.pull() source_details = svn._get_source_details() self.assertThat(source_details["source-commit"], Equals("mock-commit")) self.fake_check_call.mock.assert_called_once_with( ["svn", "checkout", "svn-repo", "svn-checkout"], stderr=-3, stdout=-3 )
def test_pull_local_relative_path(self): os.mkdir("my-source") svn = sources.Subversion("my-source", "source_dir") svn.pull() self.mock_run.assert_called_once_with( [ "svn", "checkout", "file://{}".format(os.path.join(self.path, "my-source")), "source_dir", ] )
def test_pull_existing(self): self.mock_path_exists.return_value = True svn = sources.Subversion("svn://my-source", "source_dir") svn.pull() self.mock_run.assert_called_once_with(["svn", "update"], cwd=svn.source_dir)
def test_pull_local_absolute_path(self): svn = sources.Subversion(self.path, "source_dir") svn.pull() self.mock_run.assert_called_once_with( ["svn", "checkout", "file://" + self.path, "source_dir"] )
def test_pull_remote_commit(self): svn = sources.Subversion("svn://my-source", "source_dir", source_commit="2") svn.pull() self.mock_run.assert_called_once_with( ["svn", "checkout", "svn://my-source", "source_dir", "-r", "2"] )