def test_force(self, mock_warn): resource.resource_safe_disable_cmd(self.lib, ["R1", "R2"], dict_to_modifiers({"force": True})) self.resource.disable.assert_called_once_with(["R1", "R2"], False) self.resource.disable_safe.assert_not_called() self.resource.disable_simulate.assert_not_called() mock_warn.assert_called_once_with(self.force_warning)
def test_one_resource(self): resource.resource_safe_disable_cmd( self.lib, ["R1"], dict_to_modifiers({}) ) self.resource.disable_safe.assert_called_once_with(["R1"], True, False) self.resource.disable.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_no_strict(self): resource.resource_safe_disable_cmd( self.lib, ["R1", "R2"], dict_to_modifiers({"no-strict": True})) self.resource.disable_safe.assert_called_once_with(["R1", "R2"], False, False) self.resource.disable.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_wait(self): resource.resource_safe_disable_cmd(self.lib, ["R1", "R2"], dict_to_modifiers(dict(wait="10"))) self.resource.disable_safe.assert_called_once_with(["R1", "R2"], True, "10") self.resource.disable.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_simulate(self, mock_print): self.resource.disable_simulate.return_value = self._fixture_output() resource.resource_safe_disable_cmd( self.lib, ["R1", "R2"], dict_to_modifiers(dict(simulate=True))) self.resource.disable_simulate.assert_called_once_with(["R1", "R2"], True) self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() mock_print.assert_called_once_with("simulate output")
def test_no_args(self): with self.assertRaises(CmdLineInputError) as cm: resource.resource_safe_disable_cmd(self.lib, [], dict_to_modifiers({})) self.assertEqual(cm.exception.message, "You must specify resource(s) to disable") self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_simulate_no_strict(self, mock_print): self.resource.disable_simulate.return_value = self._fixture_output() resource.resource_safe_disable_cmd( self.lib, ["R1"], dict_to_modifiers({"simulate": True, "no-strict": True}), ) self.resource.disable_simulate.assert_called_once_with(["R1"], False) self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() mock_print.assert_called_once_with("simulate output")
def test_simulate_force(self): with self.assertRaises(CmdLineInputError) as cm: resource.resource_safe_disable_cmd( self.lib, ["R1"], dict_to_modifiers(dict(simulate=True, force=True)), ) self.assertEqual(cm.exception.message, "'--force' cannot be used with '--simulate'") self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_force_no_strict(self): with self.assertRaises(CmdLineInputError) as cm: resource.resource_safe_disable_cmd( self.lib, ["R1"], dict_to_modifiers({"force": True, "no-strict": True}), ) self.assertEqual( cm.exception.message, "'--force' cannot be used with '--no-strict'" ) self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_simulate_brief(self, mock_print): self.resource.disable_simulate.return_value = self._fixture_output() resource.resource_safe_disable_cmd( self.lib, ["R1", "R2"], dict_to_modifiers(dict(simulate=True, brief=True)), ) self.resource.disable_simulate.assert_called_once_with(["R1", "R2"], True) self.report_processor.suppress_reports_of_severity.assert_not_called() self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() mock_print.assert_called_once_with("Rx\nRy")
def test_simulate_wait(self): with self.assertRaises(CmdLineInputError) as cm: resource.resource_safe_disable_cmd( self.lib, ["R1"], dict_to_modifiers(dict(simulate=True, wait=True)), ) self.assertEqual( cm.exception.message, "Only one of '--simulate', '--wait' can be used", ) self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() self.resource.disable_simulate.assert_not_called()
def test_simulate_brief_nothing_affected(self, mock_print): self.resource.disable_simulate.return_value = self._fixture_output( resources=[] ) resource.resource_safe_disable_cmd( self.lib, ["R1", "R2"], dict_to_modifiers(dict(simulate=True, brief=True)), ) self.resource.disable_simulate.assert_called_once_with( ["R1", "R2"], True ) self.resource.disable.assert_not_called() self.resource.disable_safe.assert_not_called() mock_print.assert_not_called()