def test_step_visibility(self, _step: PropertyMock): """Should return values from the internal _step object.""" _step.return_value = MagicMock(is_visible=True) es = exposed.ExposedStep() self.assertTrue(es.visible) es.visible = False self.assertFalse(es.visible)
def test_step_stop_aborted(self, _step: PropertyMock): """ Should abort stopping and not raise an error when no internal step is available to stop. """ _step.return_value = None es = exposed.ExposedStep() es.stop()
def test_write_to_console_fail(self, _step: PropertyMock): """ Should raise a ValueError when there is no current step to operate upon by the write function call. """ _step.return_value = None step = exposed.ExposedStep() with self.assertRaises(ValueError): step.write_to_console('hello')
def test_step_properties(self, _step: PropertyMock): """Should return values from the internal _step object.""" now = datetime.utcnow() _step.return_value = MagicMock(start_time=now, end_time=now, elapsed_time=0) es = exposed.ExposedStep() self.assertEqual(now, es.start_time) self.assertEqual(now, es.end_time) self.assertEqual(0, es.elapsed_time)
def test_write_to_console(self, _step: PropertyMock): """ Should write to the console using a write_source function call on the internal step report's stdout_interceptor. """ trials = [2, True, None, 'This is a test', b'hello'] for message in trials: _step_mock = MagicMock() write_source = MagicMock() _step_mock.report.stdout_interceptor.write_source = write_source _step.return_value = _step_mock step = exposed.ExposedStep() step.write_to_console(message) args, kwargs = write_source.call_args self.assertEqual('{}'.format(message), args[0])
def test_no_step_defaults(self): """Exposed step should apply defaults without project""" es = exposed.ExposedStep() self.assertIsNone(es._step)