class TestCheckUpgradeVersions(BaseTestCase): def setUp(self): context = mock.MagicMock(config=self.fake_config) self.checker = CheckUpgradeVersions(context) @mock.patch( 'fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=1) def test_check(self, compare_mock): self.checker.check() compare_mock.assert_called_once_with('0', '9999') @mock.patch( 'fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=0) def test_check_same_version_error(self, compare_mock): err_msg = 'Cannot upgrade to the same version of fuel 0 -> 9999' self.assertRaisesRegexp( errors.WrongVersionError, err_msg, self.checker.check) compare_mock.assert_called_once_with('0', '9999') @mock.patch( 'fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=-1) def test_check_higher_version_error(self, compare_mock): err_msg = 'Cannot upgrade from higher version of ' +\ 'fuel to lower 0 -> 9999' self.assertRaisesRegexp( errors.WrongVersionError, err_msg, self.checker.check) compare_mock.assert_called_once_with('0', '9999')
class TestCheckUpgradeVersions(BaseTestCase): def setUp(self): context = mock.MagicMock(config=self.fake_config) self.checker = CheckUpgradeVersions(context) @mock.patch('fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=1) def test_check(self, compare_mock): self.checker.check() compare_mock.assert_called_once_with('0', '9999') @mock.patch('fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=0) def test_check_same_version_error(self, compare_mock): err_msg = 'Cannot upgrade to the same version of fuel 0 -> 9999' self.assertRaisesRegexp(errors.WrongVersionError, err_msg, self.checker.check) compare_mock.assert_called_once_with('0', '9999') @mock.patch('fuel_upgrade.before_upgrade_checker.utils.compare_version', return_value=-1) def test_check_higher_version_error(self, compare_mock): err_msg = 'Cannot upgrade from higher version of ' +\ 'fuel to lower 0 -> 9999' self.assertRaisesRegexp(errors.WrongVersionError, err_msg, self.checker.check) compare_mock.assert_called_once_with('0', '9999')
def setUp(self): context = mock.MagicMock(config=self.fake_config) self.checker = CheckUpgradeVersions(context)
def setUp(self): self.checker = CheckUpgradeVersions(self.fake_config)