class TestBootstrapUpgrader(BaseTestCase):

    def setUp(self):
        self.upgrader = BootstrapUpgrader(self.fake_config)

    def test_constructor(self):
        self.assertEqual(len(self.upgrader._action_manager._actions), 4)

    def test_upgrade(self):
        self.upgrader._action_manager.do = mock.Mock()
        self.upgrader.upgrade()

        self.called_once(self.upgrader._action_manager.do)

    def test_rollback(self):
        self.upgrader._action_manager.undo = mock.Mock()
        self.upgrader.rollback()

        self.called_once(self.upgrader._action_manager.undo)

    @mock.patch('fuel_upgrade.utils.os.path.isdir', return_value=True)
    @mock.patch('fuel_upgrade.utils.dir_size', return_value=42)
    def test_required_free_space(self, _, __):
        result = self.upgrader.required_free_space
        self.assertEqual(result, {
            '/var/www/nailgun/9999_bootstrap': 42,
        })
class TestBootstrapUpgrader(BaseTestCase):
    def setUp(self):
        self.upgrader = BootstrapUpgrader(self.fake_config)

    def test_constructor(self):
        self.assertEqual(len(self.upgrader._action_manager._actions), 4)

    def test_upgrade(self):
        self.upgrader._action_manager.do = mock.Mock()
        self.upgrader.upgrade()

        self.called_once(self.upgrader._action_manager.do)

    def test_rollback(self):
        self.upgrader._action_manager.undo = mock.Mock()
        self.upgrader.rollback()

        self.called_once(self.upgrader._action_manager.undo)

    def test_on_success_does_not_raise_exceptions(self):
        self.upgrader.on_success()

    @mock.patch('fuel_upgrade.utils.os.path.isdir', return_value=True)
    @mock.patch('fuel_upgrade.utils.dir_size', return_value=42)
    def test_required_free_space(self, _, __):
        result = self.upgrader.required_free_space
        self.assertEqual(result, {'/var/www/nailgun/9999_bootstrap': 42})
 def setUp(self):
     self.upgrader = BootstrapUpgrader(self.fake_config)
 def setUp(self):
     self.upgrader = BootstrapUpgrader(self.fake_config)