@pytest.mark.django_db
def test_submission_ordering(en_tutorial_po, member, no_submissions):
 at_time = timezone.now()
 unit = en_tutorial_po.units[0]
 _create_comment_submission(unit, member, at_time, 'Comment 3')
 _create_comment_submission(unit, member, at_time, 'Comment 2')
 _create_comment_submission(unit, member, at_time, 'Comment 1')
 unit = en_tutorial_po.units[0]
 assert (Submission.objects.count() == 3)
 assert (Submission.objects.first().creation_time == Submission.objects.last().creation_time)
 assert (Submission.objects.latest().pk > Submission.objects.earliest().pk)
 assert (unit.submission_set.latest().pk > unit.submission_set.earliest().pk)
 assert (unit.submission_set.earliest('new_value').new_value == 'Comment 1')
 assert (unit.submission_set.latest('new_value').new_value == 'Comment 3')
 assert (unit.submission_set.earliest('pk').new_value == 'Comment 3')
 assert (unit.submission_set.latest('pk').new_value == 'Comment 1')

@ pytest . mark . django_db def test_submission_ordering ( en_tutorial_po , member , no_submissions ) : at_time = timezone . now ( ) unit = en_tutorial_po . units [ 0 ] _create_comment_submission ( unit , member , at_time , 'Comment 3' ) _create_comment_submission ( unit , member , at_time , 'Comment 2' ) _create_comment_submission ( unit , member , at_time , 'Comment 1' ) unit = en_tutorial_po . units [ 0 ] assert ( Submission . objects . count ( ) == 3 ) assert ( Submission . objects . first ( ) . creation_time == Submission . objects . last ( ) . creation_time ) assert ( Submission . objects . latest ( ) . pk > Submission . objects . earliest ( ) . pk ) assert ( unit . submission_set . latest ( ) . pk > unit . submission_set . earliest ( ) . pk ) assert ( unit . submission_set . earliest ( 'new_value' ) . new_value == 'Comment 1' ) assert ( unit . submission_set . latest ( 'new_value' ) . new_value == 'Comment 3' ) assert ( unit . submission_set . earliest ( 'pk' ) . new_value == 'Comment 3' ) assert ( unit . submission_set . latest ( 'pk' ) . new_value == 'Comment 1' )
submissions with same creation_time should order by pk .