Example #1
0
    def test_updates_existing(self, _exists, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock(return_value=True)
        self.assertTrue(bh.get(dest))
        assert(was_called_with_cmd(_call, ('bzr', 'pull', '-d', dest)))

        bh.update_branch = MagicMock(return_value=False)
        self.assertFalse(bh.get(dest))
Example #2
0
    def test_gets_revno(self, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock()

        revno = "1"
        options = {"revno": "1"}
        self.assertTrue(bh.get(dest, options))
        assert(was_called_with_cmd(_call, ('bzr', 'update', dest, '-r', revno)))
Example #3
0
    def test_updates_existing(self, _exists, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock(return_value=True)
        self.assertTrue(bh.get(dest))
        assert (was_called_with_cmd(_call, ('bzr', 'pull', '-d', dest)))

        bh.update_branch = MagicMock(return_value=False)
        self.assertFalse(bh.get(dest))
Example #4
0
    def test_gets_revno(self, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock()

        revno = "1"
        options = {"revno": "1"}
        self.assertTrue(bh.get(dest, options))
        assert (was_called_with_cmd(_call,
                                    ('bzr', 'update', dest, '-r', revno)))
Example #5
0
    def test_same_branch(self):
        parent = mkdtemp()
        self.addCleanup(shutil.rmtree, parent)
        shellcmd("bzr init {}".format(parent))
        bh = BzrSourceHandler(parent)

        child_tmp = mkdtemp()
        self.addCleanup(shutil.rmtree, child_tmp)

        # is same
        child = os.path.join(child_tmp, "child") + "/"
        shellcmd("bzr branch {} {}".format(parent, child))
        self.assertTrue(bh.is_same_branch(child))

        # is not the same
        nonchild = os.path.join(child_tmp, "nonchild")
        shellcmd("bzr branch {} {}".format(child, nonchild))
        self.assertFalse(bh.is_same_branch(nonchild), "test: is not same")

        # is standalone
        stdalone = os.path.join(child_tmp, "stdalone")
        shellcmd("bzr init {}".format(stdalone))
        self.assertFalse(bh.is_same_branch(stdalone), "test: is standalone")
Example #6
0
    def test_same_branch(self):
        parent = mkdtemp()
        self.addCleanup(shutil.rmtree, parent)
        shellcmd("bzr init {}".format(parent))
        bh = BzrSourceHandler(parent)

        child_tmp = mkdtemp()
        self.addCleanup(shutil.rmtree, child_tmp)

        # is same
        child = os.path.join(child_tmp, "child") + "/"
        shellcmd("bzr branch {} {}".format(parent, child))
        self.assertTrue(bh.is_same_branch(child))

        # is not the same
        nonchild = os.path.join(child_tmp, "nonchild")
        shellcmd("bzr branch {} {}".format(child, nonchild))
        self.assertFalse(bh.is_same_branch(nonchild), "test: is not same")

        # is standalone
        stdalone = os.path.join(child_tmp, "stdalone")
        shellcmd("bzr init {}".format(stdalone))
        self.assertFalse(bh.is_same_branch(stdalone), "test: is standalone")
Example #7
0
    def test_overwite(self, _rmtree, _exists, _log, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock(return_value=False)

        # overwrite (delete) existing when asked
        options = {"overwrite": True}
        self.assertTrue(bh.get(dest, options))
        _rmtree.assert_called_with(dest)

        bh.checkout_branch = MagicMock(return_value=False)
        self.assertFalse(bh.get(dest, options))

        # don't overwrite if not asked
        options = {"overwrite": False}
        self.assertFalse(bh.get(dest, options))
        _rmtree.assert_not_called()

        # don't overwrite if source = parent
        options = {"overwrite": True}
        bh.is_same_branch = MagicMock(return_value=True)
        self.assertTrue(bh.get(dest, options))
        _rmtree.assert_not_called()
Example #8
0
    def test_overwite(self, _rmtree, _exists, _log, _call):
        source = BzrURLs[0]
        dest = "foo"
        bh = BzrSourceHandler(source)
        bh.is_same_branch = MagicMock(return_value=False)

        # overwrite (delete) existing when asked
        options = {"overwrite": True}
        self.assertTrue(bh.get(dest, options))
        _rmtree.assert_called_with(dest)

        bh.checkout_branch = MagicMock(return_value=False)
        self.assertFalse(bh.get(dest, options))

        # don't overwrite if not asked
        options = {"overwrite": False}
        self.assertFalse(bh.get(dest, options))
        _rmtree.assert_not_called()

        # don't overwrite if source = parent
        options = {"overwrite": True}
        bh.is_same_branch = MagicMock(return_value=True)
        self.assertTrue(bh.get(dest, options))
        _rmtree.assert_not_called()