예제 #1
0
    def test_step_to_stepstatus_empty_fields(self):
        step = Step(lambda x: x, n=0)
        step_status = step_to_stepstatus(step, [])

        self.assertEqual(step_status, {
            StatusField.N: 0,
            StatusField.NAME: str(step)
        })
예제 #2
0
    def test_step_to_stepstatus_all_fields(self):
        step = Step(lambda x: x, n=0)
        step_status = step_to_stepstatus(step, [
            StatusField.STATE, StatusField.RETURN_VALUE,
            StatusField.OUTPUT_MESSAGES, StatusField.PROMPT_MESSAGES,
            StatusField.UNREPLIED_PROMPT_MESSAGE
        ])

        self.assertEqual(
            step_status, {
                StatusField.N: 0,
                StatusField.NAME: str(step),
                StatusField.STATE: Step.READY,
                StatusField.RETURN_VALUE: None,
                StatusField.OUTPUT_MESSAGES: [],
                StatusField.PROMPT_MESSAGES: [],
                StatusField.UNREPLIED_PROMPT_MESSAGE: None
            })
예제 #3
0
    def test_step_to_stepstatus_with_non_json_serializable_return_value(self):
        step = Step(lambda x: x, n=0)
        mock_exception = TypeError('is not JSON serializable')
        step.return_value = mock_exception

        step_status = step_to_stepstatus(step, [
            StatusField.STATE, StatusField.RETURN_VALUE, StatusField.TAGS,
            StatusField.OUTPUT_MESSAGES, StatusField.PROMPT_MESSAGES,
            StatusField.UNREPLIED_PROMPT_MESSAGE
        ])

        self.assertEqual(
            step_status, {
                StatusField.N: 0,
                StatusField.NAME: str(step),
                StatusField.TAGS: step.tags,
                StatusField.STATE: Step.READY,
                StatusField.RETURN_VALUE: str(mock_exception),
                StatusField.OUTPUT_MESSAGES: [],
                StatusField.PROMPT_MESSAGES: [],
                StatusField.UNREPLIED_PROMPT_MESSAGE: None
            })