@pytest.mark.django_db
def test_accept_sugg_submission_ordering(client, request_users, settings):
 settings.POOTLE_CAPTCHA_ENABLED = False
 unit = Unit.objects.filter(suggestion__state='pending', state=UNTRANSLATED)[0]
 unit.markfuzzy()
 unit.target = ('Fuzzy Translation for ' + unit.source_f)
 unit.save()
 sugg = Suggestion.objects.filter(unit=unit, state='pending')[0]
 user = request_users['user']
 if (user.username != 'nobody'):
  client.login(username=user.username, password=request_users['password'])
 url = ('/xhr/units/%d/suggestions/%d/' % (unit.id, sugg.id))
 response = client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
 if check_permission('review', response.wsgi_request):
  assert (response.status_code == 200)
  submission_field = Submission.objects.filter(unit=unit).latest().field
  assert (submission_field == SubmissionFields.TARGET)
 else:
  assert (response.status_code == 403)

@ pytest . mark . django_db def test_accept_sugg_submission_ordering ( client , request_users , settings ) : settings . POOTLE_CAPTCHA_ENABLED = False unit = Unit . objects . filter ( suggestion__state = 'pending' , state = UNTRANSLATED ) [ 0 ] unit . markfuzzy ( ) unit . target = ( 'Fuzzy Translation for ' + unit . source_f ) unit . save ( ) sugg = Suggestion . objects . filter ( unit = unit , state = 'pending' ) [ 0 ] user = request_users [ 'user' ] if ( user . username != 'nobody' ) : client . login ( username = user . username , password = request_users [ 'password' ] ) url = ( '/xhr/units/%d/suggestions/%d/' % ( unit . id , sugg . id ) ) response = client . post ( url , HTTP_X_REQUESTED_WITH = 'XMLHttpRequest' ) if check_permission ( 'review' , response . wsgi_request ) : assert ( response . status_code == 200 ) submission_field = Submission . objects . filter ( unit = unit ) . latest ( ) . field assert ( submission_field == SubmissionFields . TARGET ) else : assert ( response . status_code == 403 )
tests suggestion can be accepted with a comment .