示例#1
0
 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)
示例#2
0
 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()
示例#3
0
 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')
示例#4
0
 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)
示例#5
0
    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])
示例#6
0
 def test_no_step_defaults(self):
     """Exposed step should apply defaults without project"""
     es = exposed.ExposedStep()
     self.assertIsNone(es._step)