Exemple #1
0
    def test_init_with_source_depth_raises_exception(self):
        with self.assertRaises(sources.IncompatibleOptionsError) as raised:
            sources.Bazaar('lp://mysource', 'source_dir', source_depth=2)

        expected_message = (
            'can\'t specify source-depth for a bzr source')
        self.assertEqual(raised.exception.message, expected_message)
    def setUp(self):
        super().setUp()
        self.working_tree = 'bzr-test'
        self.source_dir = 'bzr-checkout'
        os.mkdir(self.working_tree)
        os.mkdir(self.source_dir)
        os.chdir(self.working_tree)
        call(['bzr', 'init'])
        call(['bzr', 'whoami', 'Test User <*****@*****.**>'])
        with open('testing', 'w') as fp:
            fp.write('testing')
        call(['bzr', 'add', 'testing'])
        call(['bzr', 'commit', '-m', 'testing'])
        call(['bzr', 'tag', 'test-tag'])
        self.expected_commit = call_with_output(['bzr', 'revno', '.'])
        self.expected_tag = 'test-tag'

        os.chdir('..')

        self.bzr = sources.Bazaar(self.working_tree,
                                  self.source_dir,
                                  silent=True)
        self.bzr.pull()

        self.source_details = self.bzr._get_source_details()
Exemple #3
0
    def test_bzr_details_tag(self):
        self.bzr = sources.Bazaar(self.working_tree, self.source_dir,
                                  source_tag='test-tag', silent=True)
        self.bzr.pull()

        self.source_details = self.bzr._get_source_details()
        self.assertEqual(self.expected_tag, self.source_details['tag'])
Exemple #4
0
    def test_init_with_source_branch_raises_exception(self):
        with self.assertRaises(
                sources.IncompatibleOptionsError) as raised:
            sources.Bazaar('lp:mysource', 'source_dir', source_branch='branch')

        expected_message = 'can\'t specify a source-branch for a bzr source'
        self.assertEqual(raised.exception.message, expected_message)
Exemple #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"])
Exemple #6
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"])
    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'])
Exemple #8
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))
Exemple #9
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'])
    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'])
Exemple #11
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'])
Exemple #12
0
    def test_init_with_source_tag_and_commit_raises_exception(self):
        with self.assertRaises(sources.IncompatibleOptionsError) as raised:
            sources.Bazaar('lp://mysource', 'source_dir', source_tag="tag",
                           source_commit="2")

        expected_message = (
            'can\'t specify both source-tag and source-commit for '
            'a bzr source')
        self.assertEqual(raised.exception.message, expected_message)
Exemple #13
0
    def test_bzr_details_tag(self):
        self.bzr = sources.Bazaar(self.working_tree,
                                  self.source_dir,
                                  source_tag='feature-tag',
                                  silent=True)
        self.bzr.pull()

        self.source_details = self.bzr._get_source_details()
        self.assertEqual('feature-tag', self.source_details['source-tag'])
Exemple #14
0
    def test_bzr_details_tag(self):
        self.bzr = sources.Bazaar(self.working_tree,
                                  self.source_dir,
                                  source_tag="feature-tag",
                                  silent=True)
        self.bzr.pull()

        self.source_details = self.bzr._get_source_details()
        self.assertThat(self.source_details["source-tag"],
                        Equals("feature-tag"))
Exemple #15
0
    def setUp(self):
        super().setUp()
        self.working_tree = "bzr-test"
        self.bzr_repo = fixture_setup.BzrRepo(self.working_tree)
        self.useFixture(self.bzr_repo)
        self.source_dir = "bzr-checkout"
        os.mkdir(self.source_dir)

        self.bzr = sources.Bazaar(self.working_tree,
                                  self.source_dir,
                                  silent=True)
        self.bzr.pull()

        self.source_details = self.bzr._get_source_details()
Exemple #16
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"])
Exemple #17
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"])