Пример #1
0
    def test_run_tasks(self):
        # Crate a mocked method
        m_method = mock.Mock()
        m_run = FirstTimeRun()

        m_run.add_task(self.fake_task)
        # Force mocked method into the tasks list
        m_run._tasks.append(m_method)

        m_run._run_tasks()

        m_method.assert_called_once()
Пример #2
0
    def test_constructor(self):
        m_method = mock.Mock()

        self.assertEqual(0, len(FirstTimeRun._tasks))
        self.assertEqual(0, len(FirstTimeRun._checks))

        FirstTimeRun.add_check(self.fake_check_true)
        FirstTimeRun.add_check(self.fake_check_false)
        FirstTimeRun.add_task(self.fake_task())
        FirstTimeRun._tasks.append(m_method)

        FirstTimeRun()

        m_method.assert_called_once()
Пример #3
0
    def test_run_tasks_error(self, m_log):
        # Crate a mocked method
        m_method = mock.Mock()
        m_method.side_effect = Exception("Whoops")
        m_run = FirstTimeRun()

        m_run.add_task(self.fake_task)
        # Force mocked method into the tasks list
        m_run._tasks.append(m_method)

        m_run._run_tasks()

        m_method.assert_called_once()
        m_log.error.assert_called_once()
Пример #4
0
    def test_add_task_fake(self):
        FirstTimeRun.add_task(True)

        self.assertEqual(0, len(FirstTimeRun._tasks))
Пример #5
0
    def test_add_task(self):
        FirstTimeRun.add_task(self.fake_task)

        self.assertEqual(1, len(FirstTimeRun._tasks))