Example #1
0
    def get_activity_states(self, history):
        """Get the activity states from the history.

        From the full history extract the different activity states. Those
        states contain

        Args:
            history (list): the full history.
        Return:
            dict: list of all the activities and their state. It only contains
                activities that have been scheduled with AWS.
        """

        return event.activity_states_from_events(history)
Example #2
0
    def get_activity_states(self, history):
        """Get the activity states from the history.

        From the full history extract the different activity states. Those
        states contain

        Args:
            history (list): the full history.
        Return:
            dict: list of all the activities and their state. It only contains
                activities that have been scheduled with AWS.
        """

        return event.activity_states_from_events(history)
Example #3
0
def test_activity_launch_sequence():
    """Test available activities.
    """

    from tests.fixtures.flows import example

    # First available activity is the activity_1.
    history = event.activity_states_from_events(decider.history[:1])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 1
    assert len(uncomplete) == 4
    assert activities[0] == example.activity_1

    # In between activities should not launch activities.
    history = event.activity_states_from_events(decider.history[:5])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 0
    assert len(uncomplete) == 4

    # Two activities are launched in parallel: 2 and 3.
    history = event.activity_states_from_events(decider.history[:7])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 2
    assert example.activity_1 not in uncomplete

    # Activity 3 completes before activity 2. Activity 4 depends on 2 and 3 to
    # complete.
    history = event.activity_states_from_events(decider.history[:14])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 0
    assert example.activity_3 not in uncomplete

    # Activity 2 - 3 completed.
    history = event.activity_states_from_events(decider.history[:22])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 1
    assert activities[0] == example.activity_4
    assert example.activity_1 not in uncomplete
    assert example.activity_2 not in uncomplete
    assert example.activity_3 not in uncomplete

    # Close
    history = event.activity_states_from_events(decider.history[:25])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert not activities
    assert not uncomplete
Example #4
0
def test_activity_launch_sequence():
    """Test available activities.
    """

    from tests.fixtures.flows import example

    # First available activity is the activity_1.
    history = event.activity_states_from_events(decider.history[:1])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 1
    assert len(uncomplete) == 4
    assert activities[0] == example.activity_1

    # In between activities should not launch activities.
    history = event.activity_states_from_events(decider.history[:5])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 0
    assert len(uncomplete) == 4

    # Two activities are launched in parallel: 2 and 3.
    history = event.activity_states_from_events(decider.history[:7])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 2
    assert example.activity_1 not in uncomplete

    # Activity 3 completes before activity 2. Activity 4 depends on 2 and 3 to
    # complete.
    history = event.activity_states_from_events(decider.history[:14])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 0
    assert example.activity_3 not in uncomplete

    # Activity 2 - 3 completed.
    history = event.activity_states_from_events(decider.history[:22])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert len(activities) == 1
    assert activities[0] == example.activity_4
    assert example.activity_1 not in uncomplete
    assert example.activity_2 not in uncomplete
    assert example.activity_3 not in uncomplete

    # Close
    history = event.activity_states_from_events(decider.history[:25])
    activities = list(activity.find_available_activities(example, history))
    uncomplete = list(activity.find_uncomplete_activities(example, history))
    assert not activities
    assert not uncomplete