def testPlaybookOnStart_RunnerFailure_KirbyIsDisabled(self, mock_subprocess): devnull = open(os.devnull, 'w') with patch('sys.stderr', devnull): callbacks = CallbackModule() callbacks.playbook_on_start() self.assertFalse(callbacks.setting_manager.enable)
def testPlaybookOnTaskStart_DirtyFlagSetAndCoverageSkip_NotRunServerspec(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.dirty = True callbacks.playbook_on_task_start('it\'s me [coverage_skip]', False) self.assertEqual(callbacks.num_failed_tests, 2) self.assertEqual(callbacks.dirty, True)
def testPlaybookOnTaskStart_DirtyFlagSet_RunServerspec(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.dirty = True callbacks.playbook_on_task_start('it\'s me', False) self.assertEqual(callbacks.num_failed_tests, 1) self.assertEqual(callbacks.dirty, False)
def testRunnerOnOk_ChangedAndNotTestedTask_AddToFailTasks(self, mock_stdout, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me', False) callbacks.runner_on_ok('localhost', {'changed': True}) self.assertEqual(callbacks.num_tested_tasks, 0) self.assertEqual(callbacks.not_tested_tasks, ['it\'s me'])
def testPlaybookOnStats_DirtyFlagSet_RunServerspec(self, mock_stdout, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me [coverage_skip]', False) callbacks.runner_on_ok('localhost', {'changed': True}) callbacks.playbook_on_stats(None) self.assertEqual(callbacks.num_failed_tests, 1) self.assertEqual(callbacks.dirty, False)
def testRunnerOnOk_CoverageSkipTask_NotIncNumChangedTasks(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me (coverage_skip)', False) callbacks.runner_on_ok('localhost', {'changed': True}) self.assertEqual(callbacks.dirty, True) # since serverspec is not run, # of failed tests should not be updated self.assertEqual(callbacks.num_failed_tests, 2)
def testRunnerOnOk_ChangedAndNotTestedTask_ShowTestedBy(self, mock_stdout, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me', False) callbacks.runner_on_ok('localhost', {'changed': True}) result = mock_stdout.getvalue() self.assertIn('tested by:', result) self.assertNotIn('rspec', result)
def testPlaybookOnStats_NoTestedTask_Coverage0(self, mock_stdout, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me', False) callbacks.runner_on_ok('localhost', {'changed': True}) callbacks.playbook_on_stats(None) result = mock_stdout.getvalue() self.assertIn(' 0%', result) self.assertIn('it\'s me', result) self.assertIn('WARNING:', result)
def testPlaybookOnTaskStart_KirbyIsEnabled_TaskNameSet(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_task_start('it\'s me', False) self.assertEqual(callbacks.curr_task_name, 'it\'s me')
def testPlaybookOnSetup_KirbyIsEnabled_TaskNameSet(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() callbacks.playbook_on_setup() self.assertEqual(callbacks.curr_task_name, 'setup')
def testPlaybookOnStart_RunnerSuccessful_KirbyIsEnabled(self, mock_subprocess): callbacks = CallbackModule() callbacks.playbook_on_start() self.assertTrue(callbacks.setting_manager.enable)