Пример #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_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()