Example #1
0
    def test_storycreation(self):
        story = Story()
        story.append(Event('a'))
        story.append(Event('b'))
        story.append(Pause(10))
        story.append(Event('c'))

        self.assertEqual(len(story), 4)
Example #2
0
    def test_storycreation(self):
        story = Story()
        story.append(Event('a'))
        story.append(Event('b'))
        story.append(Pause(10))
        story.append(Event('c'))

        self.assertEqual(len(story), 4)
Example #3
0
def teststory_from_trace(trace: list) -> Story:
    """
    Return a test story based on the given *trace*, a list of macro steps.
    See documentation to see which are the events that are generated.

    Notice that this function adds a *pause* if there is any delay between pairs of consecutive steps.

    :param trace: a list of *MacroStep* instances
    :return: A story
    """
    story = Story()
    story.append(Event('execution started'))
    time = 0

    for macrostep in trace:
        if macrostep.time > time:
            story.append(Pause(macrostep.time - time))
        story.extend(_teststory_from_macrostep(macrostep))
        time = macrostep.time

    story.append(Event('execution stopped'))
    return story
Example #4
0
def teststory_from_trace(trace: list) -> Story:
    """
    Return a test story based on the given *trace*, a list of macro steps.
    See documentation to see which are the events that are generated.

    Notice that this function adds a *pause* if there is any delay between pairs of consecutive steps.

    :param trace: a list of *MacroStep* instances
    :return: A story
    """
    story = Story()
    story.append(Event('execution started'))
    time = 0

    for macrostep in trace:
        if macrostep.time > time:
            story.append(Pause(macrostep.time - time))
        story.extend(_teststory_from_macrostep(macrostep))
        time = macrostep.time

    story.append(Event('execution stopped'))
    return story
Example #5
0
def _teststory_from_macrostep(macrostep: MacroStep) -> Story:
    story = Story()
    story.append(Event('step started'))

    if macrostep.event:
        story.append(Event('event consumed', event=macrostep.event))

    for microstep in macrostep.steps:
        for state in microstep.exited_states:
            story.append(Event('state exited', state=state))
        if microstep.transition:
            story.append(Event('transition processed', source=microstep.transition.source,
                               target=microstep.transition.target,
                               event=macrostep.event))
        for state in microstep.entered_states:
            story.append(Event('state entered', state=state))

    story.append(Event('step ended'))
    return story
Example #6
0
def _teststory_from_macrostep(macrostep: MacroStep) -> Story:
    story = Story()
    story.append(Event('step started'))

    if macrostep.event:
        story.append(Event('event consumed', event=macrostep.event))

    for microstep in macrostep.steps:
        for state in microstep.exited_states:
            story.append(Event('state exited', state=state))
        if microstep.transition:
            story.append(Event('transition processed', source=microstep.transition.source,
                               target=microstep.transition.target,
                               event=macrostep.event))
        for state in microstep.entered_states:
            story.append(Event('state entered', state=state))

    story.append(Event('step ended'))
    return story