@pytest.mark.django_db
def test_add_suggestion(store0, system):
 untranslated_unit = store0.units.filter(state=UNTRANSLATED)[0]
 translated_unit = store0.units.filter(state=TRANSLATED)[0]
 suggestion_text = 'foo bar baz'
 initial_suggestions = len(untranslated_unit.get_suggestions())
 suggestions = review.get(Suggestion)()
 (sugg, added) = suggestions.add(untranslated_unit, '')
 assert (sugg is None)
 assert (not added)
 (sugg, added) = suggestions.add(translated_unit, translated_unit.target)
 assert (sugg is None)
 assert (not added)
 (sugg, added) = suggestions.add(untranslated_unit, suggestion_text)
 assert (sugg is not None)
 assert added
 assert (len(untranslated_unit.get_suggestions()) == (initial_suggestions + 1))
 (sugg, added) = suggestions.add(untranslated_unit, suggestion_text)
 assert (sugg is not None)
 assert (not added)
 assert (len(untranslated_unit.get_suggestions()) == (initial_suggestions + 1))
 review.get(Suggestion)([sugg], system).reject()
 assert (len(untranslated_unit.get_suggestions()) == initial_suggestions)
 (sugg, added) = suggestions.add(untranslated_unit, suggestion_text)
 assert (sugg is not None)
 assert added
 assert (len(untranslated_unit.get_suggestions()) == (initial_suggestions + 1))

@ pytest . mark . django_db def test_add_suggestion ( store0 , system ) : untranslated_unit = store0 . units . filter ( state = UNTRANSLATED ) [ 0 ] translated_unit = store0 . units . filter ( state = TRANSLATED ) [ 0 ] suggestion_text = 'foo bar baz' initial_suggestions = len ( untranslated_unit . get_suggestions ( ) ) suggestions = review . get ( Suggestion ) ( ) ( sugg , added ) = suggestions . add ( untranslated_unit , '' ) assert ( sugg is None ) assert ( not added ) ( sugg , added ) = suggestions . add ( translated_unit , translated_unit . target ) assert ( sugg is None ) assert ( not added ) ( sugg , added ) = suggestions . add ( untranslated_unit , suggestion_text ) assert ( sugg is not None ) assert added assert ( len ( untranslated_unit . get_suggestions ( ) ) == ( initial_suggestions + 1 ) ) ( sugg , added ) = suggestions . add ( untranslated_unit , suggestion_text ) assert ( sugg is not None ) assert ( not added ) assert ( len ( untranslated_unit . get_suggestions ( ) ) == ( initial_suggestions + 1 ) ) review . get ( Suggestion ) ( [ sugg ] , system ) . reject ( ) assert ( len ( untranslated_unit . get_suggestions ( ) ) == initial_suggestions ) ( sugg , added ) = suggestions . add ( untranslated_unit , suggestion_text ) assert ( sugg is not None ) assert added assert ( len ( untranslated_unit . get_suggestions ( ) ) == ( initial_suggestions + 1 ) )
tests translation can be applied after suggestion is accepted .