예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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'])
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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')
예제 #10
0
    def testPlaybookOnSetup_KirbyIsEnabled_TaskNameSet(self, mock_subprocess):
        callbacks = CallbackModule()
        callbacks.playbook_on_start()
        callbacks.playbook_on_setup()

        self.assertEqual(callbacks.curr_task_name, 'setup')
예제 #11
0
    def testPlaybookOnStart_RunnerSuccessful_KirbyIsEnabled(self, mock_subprocess):
        callbacks = CallbackModule()
        callbacks.playbook_on_start()

        self.assertTrue(callbacks.setting_manager.enable)