示例#1
0
    def test_pull_commit(self):
        bzr = sources.Bazaar("lp:my-source", "source_dir", source_commit="2")
        bzr.pull()

        self.mock_run.assert_called_once_with(
            ["bzr", "branch", "-r", "2", "lp:my-source", "source_dir"]
        )
示例#2
0
    def test_pull_tag(self):
        bzr = sources.Bazaar("lp:my-source", "source_dir", source_tag="tag")
        bzr.pull()

        self.mock_run.assert_called_once_with(
            ["bzr", "branch", "-r", "tag:tag", "lp:my-source", "source_dir"]
        )
示例#3
0
    def test_pull_failure(self):
        self.mock_run.side_effect = subprocess.CalledProcessError(1, [])

        bzr = sources.Bazaar("lp:my-source", "source_dir")
        raised = self.assertRaises(sources.errors.SnapcraftPullError, bzr.pull)
        self.assertThat(raised.command, Equals("bzr branch lp:my-source source_dir"))
        self.assertThat(raised.exit_code, Equals(1))
示例#4
0
    def test_pull_existing_with_commit(self):
        self.mock_path_exists.return_value = True

        bzr = sources.Bazaar("lp:my-source", "source_dir", source_commit="2")
        bzr.pull()

        self.mock_run.assert_called_once_with(
            ["bzr", "pull", "-r", "2", "lp:my-source", "-d", "source_dir"]
        )
示例#5
0
    def test_pull(self):
        bzr = sources.Bazaar("lp:my-source", "source_dir")

        bzr.pull()

        self.mock_rmdir.assert_called_once_with("source_dir")
        self.mock_run.assert_called_once_with(
            ["bzr", "branch", "lp:my-source", "source_dir"]
        )
示例#6
0
    def test_bzr_details_commit(self):
        bzr = sources.Bazaar(self.working_tree, self.source_dir, silent=True)
        bzr.pull()

        source_details = bzr._get_source_details()

        self.assertThat(source_details["source-commit"], Equals("mock-commit"))

        self.fake_check_output.mock.assert_has_calls(
            [
                mock.call(["bzr", "revno", self.source_dir]),
                mock.call(["bzr", "revno", self.source_dir]),
            ]
        )
        self.fake_check_call.mock.assert_called_once_with(
            ["bzr", "pull", self.working_tree, "-d", self.source_dir],
            stderr=-3,
            stdout=-3,
        )
示例#7
0
    def test_bzr_details_tag(self):
        bzr = sources.Bazaar(
            self.working_tree, self.source_dir, source_tag="mock-tag", silent=True
        )
        bzr.pull()

        source_details = bzr._get_source_details()
        self.assertThat(source_details["source-tag"], Equals("mock-tag"))

        self.fake_check_output.mock.assert_not_called()
        self.fake_check_call.mock.assert_called_once_with(
            [
                "bzr",
                "pull",
                "-r",
                "tag:mock-tag",
                self.working_tree,
                "-d",
                self.source_dir,
            ],
            stderr=-3,
            stdout=-3,
        )