def test_init_with_source_tag_raises_exception(self): with self.assertRaises(sources.IncompatibleOptionsError) as raised: sources.Subversion('svn://mysource', 'source_dir', source_tag='tag') expected_message = ("Can't specify source-tag for a Subversion source") self.assertEqual(raised.exception.message, expected_message)
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"])
def test_init_with_source_depth_raises_exception(self): with self.assertRaises(sources.IncompatibleOptionsError) as raised: sources.Subversion('svn://mysource', 'source_dir', source_depth=2) expected_message = ( 'can\'t specify source-depth for a Subversion source') self.assertEqual(raised.exception.message, expected_message)
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'])
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_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_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_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 setUp(self): super().setUp() self.repo_tree = "svn-repo" self.working_tree = "svn-test" self.source_dir = "svn-checkout" self.clean_dir(self.repo_tree) self.clean_dir(self.working_tree) call(["svnadmin", "create", self.repo_tree]) self.clone_repo(self.repo_tree, self.working_tree) os.chdir(self.working_tree) self.add_file("testing", "test body", "test message") self.expected_commit = "1" os.chdir("..") self.svn = sources.Subversion(self.repo_tree, self.source_dir, silent=True) self.svn.pull() self.source_details = self.svn._get_source_details()
def setUp(self): super().setUp() self.repo_tree = 'svn-repo' self.working_tree = 'svn-test' self.source_dir = 'svn-checkout' self.clean_dir(self.repo_tree) self.clean_dir(self.working_tree) call(['svnadmin', 'create', self.repo_tree]) self.clone_repo(self.repo_tree, self.working_tree) os.chdir(self.working_tree) self.add_file('testing', 'test body', 'test message') self.expected_commit = '1' os.chdir('..') self.svn = sources.Subversion(self.repo_tree, self.source_dir, silent=True) self.svn.pull() self.source_details = self.svn._get_source_details()
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_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'])