def test_no_args(self, mock_deprecation): with self.assertRaises(CmdLineInputError) as cm: resource.resource_move(self.lib, [], dict_to_modifiers(dict())) self.assertEqual(cm.exception.message, "must specify a resource to move") self.resource.move_autoclean.assert_not_called() mock_deprecation.assert_not_called()
def test_success(self, mock_deprecation): resource.resource_move(self.lib, ["resource"], dict_to_modifiers({})) self.resource.move_autoclean.assert_called_once_with("resource", node=None, master=False, wait_timeout=-1, strict=False) mock_deprecation.assert_not_called()
def test_success_wait(self, mock_warn): resource.resource_move(self.lib, ["resource", "node"], dict_to_modifiers(dict(wait=None))) self.resource.move_autoclean.assert_called_once_with("resource", node="node", master=False, wait_timeout=0, strict=False) mock_warn.assert_not_called()
def test_too_many_args(self, mock_deprecation): with self.assertRaises(CmdLineInputError) as cm: resource.resource_move( self.lib, ["resource", "arg1", "arg2"], dict_to_modifiers(dict()), ) self.assertIsNone(cm.exception.message) self.resource.move_autoclean.assert_not_called() mock_deprecation.assert_not_called()
def test_success_all_options(self, mock_warn): resource.resource_move( self.lib, ["resource", "node"], dict_to_modifiers(dict(promoted=True, strict=True, wait="10")), ) self.resource.move_autoclean.assert_called_once_with("resource", node="node", master=True, wait_timeout=10, strict=True) mock_warn.assert_not_called()
def test_success_autodelete(self, mock_deprecation): resource.resource_move( self.lib, ["resource", "node"], dict_to_modifiers(dict(autodelete=True)), ) self.resource.move_autoclean.assert_called_once_with("resource", node="node", master=False, wait_timeout=-1, strict=False) mock_deprecation.assert_called_once_with( "Option '--autodelete' is deprecated. There is no need to use it " "as its functionality is default now.")