@pytest.mark.django_db
def test_submit_fuzzy(rf, po_directory, admin, default, store0):
 language = store0.translation_project.language
 unit = store0.units[0]
 directory = unit.store.parent
 post_dict = {'id': unit.id, 'index': unit.index, 'target_f_0': unit.target_f, 'state': FUZZY}
 request = _create_post_request(rf, directory, data=post_dict, user=admin)
 admin_form = _create_unit_form(request, language, unit)
 assert admin_form.is_valid()
 request = _create_post_request(rf, directory, data=post_dict, user=default)
 user_form = _create_unit_form(request, language, unit)
 assert (not user_form.is_valid())
 assert ('state' in user_form.errors)

@ pytest . mark . django_db def test_submit_fuzzy ( rf , po_directory , admin , default , store0 ) : language = store0 . translation_project . language unit = store0 . units [ 0 ] directory = unit . store . parent post_dict = { 'id' : unit . id , 'index' : unit . index , 'target_f_0' : unit . target_f , 'state' : FUZZY } request = _create_post_request ( rf , directory , data = post_dict , user = admin ) admin_form = _create_unit_form ( request , language , unit ) assert admin_form . is_valid ( ) request = _create_post_request ( rf , directory , data = post_dict , user = default ) user_form = _create_unit_form ( request , language , unit ) assert ( not user_form . is_valid ( ) ) assert ( 'state' in user_form . errors )
tests that non-admin users cant set the fuzzy flag .