def test_default_input_apply_single_nothing(self): action = TestAction() args = [ self.console_printer, Section(''), [action.get_metadata()], { 'TestAction': action }, set(), Result('origin', 'message'), {}, {}, {} ] with simulate_console_inputs(1, 'a') as generator: apply_single = 'Do (N)othing' se = Section('cli') args = [ self.console_printer, se, [action.get_metadata()], { 'TestAction': action }, set(), Result('origin', 'message'), {}, {}, {}, apply_single ] self.assertFalse(ask_for_action_and_apply(*args)) with simulate_console_inputs('') as generator: self.assertFalse(ask_for_action_and_apply(*args))
def test_ask_for_actions_and_apply(self): failed_actions = set() action = TestAction() do_nothing_action = DoNothingAction() args = [ self.console_printer, Section(''), [do_nothing_action.get_metadata(), action.get_metadata()], { 'DoNothingAction': do_nothing_action, 'TestAction': action }, failed_actions, Result('origin', 'message'), {}, {}, {} ] with simulate_console_inputs('a', 'param1', 'a', 'param2') as generator: action.apply = unittest.mock.Mock(side_effect=AssertionError) ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 1) self.assertIn('TestAction', failed_actions) action.apply = lambda *args, **kwargs: {} ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 3) self.assertNotIn('TestAction', failed_actions)
def test_ask_for_actions_and_apply5(self): failed_actions = set() action = ApplyPatchAction() action2 = ChainPatchAction() args = [self.console_printer, Section(''), [action.get_metadata(), action2.get_metadata()], {'ApplyPatchAction': action, 'ChainPatchAction': action2}, failed_actions, Result('origin', 'message'), {}, {}] with simulate_console_inputs('c', 'i') as generator: ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 1) self.assertNotIn('ChainPatchAction', failed_actions)
def test_default_input(self): action = TestAction() args = [self.console_printer, Section(''), [action.get_metadata()], {'TestAction': action}, set(), Result('origin', 'message'), {}, {}] with simulate_console_inputs('') as generator: self.assertFalse(ask_for_action_and_apply(*args))
def test_ask_for_actions_and_apply(self): failed_actions = set() action = TestAction() args = [self.console_printer, Section(''), [action.get_metadata()], {'TestAction': action}, failed_actions, Result('origin', 'message'), {}, {}] with simulate_console_inputs(1, 'param1', 1, 'param2') as generator: action.apply = unittest.mock.Mock(side_effect=AssertionError) ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 1) self.assertIn('TestAction', failed_actions) action.apply = lambda *args, **kwargs: {} ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 3) self.assertNotIn('TestAction', failed_actions)
def test_ask_for_actions_and_apply(self): failed_actions = set() action = TestAction() args = [self.log_printer, self.console_printer, Section(""), [action.get_metadata()], {'TestAction': action}, failed_actions, Result("origin", "message"), {}, {}] with simulate_console_inputs(1, 'param1', 1, 'param2') as generator: action.apply = unittest.mock.Mock(side_effect=AssertionError) ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 1) self.assertIn('TestAction', failed_actions) action.apply = lambda *args, **kwargs: {} ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 3) self.assertNotIn('TestAction', failed_actions)
def test_default_input_apply_single_nothing(self): action = TestAction() args = [self.console_printer, Section(''), [action.get_metadata()], {'TestAction': action}, set(), Result('origin', 'message'), {}, {}, {}] with simulate_console_inputs(1, 'a') as generator: apply_single = 'Do (N)othing' se = Section('cli') args = [self.console_printer, se, [action.get_metadata()], {'TestAction': action}, set(), Result('origin', 'message'), {}, {}, {}, apply_single] self.assertFalse(ask_for_action_and_apply(*args)) with simulate_console_inputs('') as generator: self.assertFalse(ask_for_action_and_apply(*args))
def test_ask_for_actions_and_apply(self): failed_actions = set() action = TestAction() args = [self.log_printer, self.console_printer, Section(""), [action.get_metadata()], {'TestAction': action}, failed_actions, Result("origin", "message"), {}, {}] with simulate_console_inputs(1, 'param1', 1, 'param2') as generator: action.apply = lambda *args, **kwargs: raise_error(AssertionError) ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 1) self.assertIn('TestAction', failed_actions) action.apply = lambda *args, **kwargs: {} ask_for_action_and_apply(*args) self.assertEqual(generator.last_input, 3) self.assertNotIn('TestAction', failed_actions)
def test_default_input_apply_single_test(self): action = TestAction() do_nothing_action = DoNothingAction() apply_single = 'Test (A)ction' se = Section('cli') args = [self.console_printer, se, [do_nothing_action.get_metadata(), action.get_metadata()], {'DoNothingAction': do_nothing_action, 'TestAction': action}, set(), Result('origin', 'message'), {}, {}, {}, apply_single] with simulate_console_inputs('a') as generator: self.assertFalse(ask_for_action_and_apply(*args))
def test_default_input_apply_single_test(self): action = TestAction() do_nothing_action = DoNothingAction() apply_single = 'Test (A)ction' se = Section('cli') args = [self.console_printer, se, [do_nothing_action.get_metadata(), action.get_metadata()], {'DoNothingAction': do_nothing_action, 'TestAction': action}, set(), Result('origin', 'message'), {}, {}, {}, apply_single] with simulate_console_inputs('a') as generator: self.assertTrue(ask_for_action_and_apply(*args))
def test_default_input2(self): action = TestAction() do_nothing_action = DoNothingAction() args = [ self.console_printer, Section(''), [do_nothing_action.get_metadata(), action.get_metadata()], { 'DoNothingAction': do_nothing_action, 'TestAction': action }, set(), Result('origin', 'message'), {}, {}, {} ] with simulate_console_inputs(1, 1) as generator: self.assertTrue(ask_for_action_and_apply(*args))