def _verify_iteration_datetimes(iterations):
    for iteration in iterations:
        assignment = iteration.assignment
        siblings = assignment.iterations.order_by('start_datetime')
        if siblings.first() == iteration:
            # If iteration is first in assignment, expected start datetime
            # is when the assignment was picked up rather than the end of
            # the previous iteration
            expected_start_datetime = assignment.start_datetime

        assert iteration.start_datetime == expected_start_datetime
        # The expected start datetime for the next iteration should be the
        # end datetime of the current one, unless the next iteration is the
        # first in its assignment
        expected_start_datetime = iteration.end_datetime

        # If iteration is processing, it should not have an end datetime
        if iteration.status == Iteration.Status.PROCESSING:
            assert not iteration.end_datetime
Verifies correct start and end datetimes for ordered iterations.
dataset/ETHPy150Open unlimitedlabs/orchestra/orchestra/tests/helpers/iterations.py/_verify_iteration_datetimes