예제 #1
0
파일: unit.py 프로젝트: sjhale/pootle
def test_submit_with_suggestion_and_comment(client, request_users, settings):
    """Tests translation can be applied after suggestion is accepted."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state='pending',
                               state=UNTRANSLATED)[0]
    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/' % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = 'This is a comment!'

    response = client.post(url, {
        'state': False,
        'target_f_0': edited_target,
        'suggestion': sugg.id,
        'comment': comment
    },
                           HTTP_X_REQUESTED_WITH='XMLHttpRequest')

    if check_permission('translate', response.wsgi_request):
        assert response.status_code == 200
        accepted_suggestion = Suggestion.objects.get(id=sugg.id)
        updated_unit = Unit.objects.get(id=unit.id)

        assert accepted_suggestion.state == 'accepted'
        assert str(updated_unit.target) == edited_target
        assert (Comment.objects.for_model(accepted_suggestion).get().comment ==
                comment)
    else:
        assert response.status_code == 403
예제 #2
0
파일: unit.py 프로젝트: YESLTD/pootle
def test_reject_suggestion_with_comment(client, request_users):
    """Tests suggestion can be rejected with a comment."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state__name='pending',
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state__name='pending')[0]
    comment = 'This is a comment!'
    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.delete(url,
                             'comment=%s' % comment,
                             HTTP_X_REQUESTED_WITH='XMLHttpRequest')

    can_reject = (check_permission('review', response.wsgi_request)
                  or sugg.user.id == user.id)
    suggestion = Suggestion.objects.get(id=sugg.id)
    if can_reject:
        assert response.status_code == 200
        assert suggestion.state.name == 'rejected'
        assert unit.target == ""
        # unit is untranslated so no change
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
        assert (Comment.objects.for_model(suggestion).get().comment == comment)
    else:
        assert response.status_code == 404
        assert unit.target == ""
        assert suggestion.state.name == "pending"
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
예제 #3
0
파일: unit.py 프로젝트: Finntack/pootle
def test_accept_suggestion_with_comment(client, request_users, settings):
    """Tests suggestion can be accepted with a comment."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state='pending',
                               state=UNTRANSLATED)[0]
    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)
    comment = 'This is a comment!'
    response = client.post(
        url,
        {
            'comment': comment
        },
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    if check_permission('review', response.wsgi_request):
        assert response.status_code == 200
        accepted_suggestion = Suggestion.objects.get(id=sugg.id)
        updated_unit = Unit.objects.get(id=unit.id)

        assert accepted_suggestion.state == 'accepted'
        assert str(updated_unit.target) == str(sugg.target)
        assert (Comment.objects
                       .for_model(accepted_suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 403
예제 #4
0
파일: unit.py 프로젝트: Finntack/pootle
def test_reject_suggestion_with_comment(client, request_users):
    """Tests suggestion can be rejected with a comment."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state='pending',
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state='pending')[0]
    comment = 'This is a comment!'
    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.delete(
        url,
        'comment=%s' % comment,
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    can_reject = (
        check_permission('review', response.wsgi_request)
        or sugg.user.id == user.id
    )
    if can_reject:
        assert response.status_code == 200
        rejected_suggestion = Suggestion.objects.get(id=sugg.id)

        assert rejected_suggestion.state == 'rejected'
        assert (Comment.objects
                       .for_model(rejected_suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 403
예제 #5
0
파일: unit.py 프로젝트: sshyran/zing
def test_reject_suggestion_with_comment(client, request_users):
    """Tests suggestion can be rejected with a comment."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state="pending",
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state="pending")[0]
    comment = "This is a comment!"
    user = request_users["user"]
    if user.username != "nobody":
        client.force_login(user)

    url = "/xhr/units/%d/suggestions/%d/" % (unit.id, sugg.id)
    response = client.delete(url,
                             "comment=%s" % comment,
                             HTTP_X_REQUESTED_WITH="XMLHttpRequest")

    can_reject = (check_permission("review", response.wsgi_request)
                  or sugg.user.id == user.id)
    if can_reject:
        assert response.status_code == 200
        rejected_suggestion = Suggestion.objects.get(id=sugg.id)

        assert rejected_suggestion.state == "rejected"
        assert Comment.objects.for_model(
            rejected_suggestion).get().comment == comment
    else:
        assert response.status_code == 403
예제 #6
0
파일: unit.py 프로젝트: sshyran/zing
def test_accept_suggestion_with_comment(client, request_users):
    """Tests suggestion can be accepted with a comment."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state="pending",
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state="pending")[0]
    user = request_users["user"]
    if user.username != "nobody":
        client.force_login(user)

    url = "/xhr/units/%d/suggestions/%d/" % (unit.id, sugg.id)
    comment = "This is a comment!"
    response = client.post(url, {"comment": comment},
                           HTTP_X_REQUESTED_WITH="XMLHttpRequest")

    if check_permission("review", response.wsgi_request):
        assert response.status_code == 200
        accepted_suggestion = Suggestion.objects.get(id=sugg.id)
        updated_unit = Unit.objects.get(id=unit.id)

        assert accepted_suggestion.state == "accepted"
        assert str(updated_unit.target) == str(sugg.target)
        assert Comment.objects.for_model(
            accepted_suggestion).get().comment == comment
    else:
        assert response.status_code == 403
예제 #7
0
파일: timeline.py 프로젝트: ta2-1/pootle
 def comment_dict(self):
     Comment = get_comment_model()
     return dict([
         # we need convert `object_pk` because it is TextField
         (int(x[0]), x[1])
         for x in Comment.objects.for_model(Suggestion)
                                 .filter(object_pk__in=self.suggestion_ids)
                                 .values_list("object_pk", "comment")
     ])
예제 #8
0
 def comment_dict(self):
     Comment = get_comment_model()
     return dict([
         # we need convert `object_pk` because it is TextField
         (int(x[0]), x[1])
         for x in Comment.objects.for_model(Suggestion)
                                 .filter(object_pk__in=self.suggestion_ids)
                                 .values_list("object_pk", "comment")
     ])
예제 #9
0
def test_submit_with_suggestion_and_comment(client, request_users,
                                            settings, system):
    """Tests translation can be applied after suggestion is accepted."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state='pending',
                               state=UNTRANSLATED)[0]
    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/' % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = 'This is a comment!'

    response = client.post(
        url,
        {
            'state': False,
            'target_f_0': edited_target,
            'suggestion': sugg.id,
            'comment': comment
        },
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    suggestion = Suggestion.objects.get(id=sugg.id)
    unit = Unit.objects.get(id=unit.id)
    if check_permission('translate', response.wsgi_request):
        assert response.status_code == 200

        content = json.loads(response.content)

        assert content['newtargets'] == [edited_target]
        assert content['user_score'] == response.wsgi_request.user.public_score
        assert content['checks'] is None
        unit_source = unit.unit_source.get()
        assert unit_source.created_by == system
        assert unit_source.created_with == SubmissionTypes.SYSTEM
        assert unit.change.submitted_by == suggestion.user
        assert unit.change.reviewed_by == user
        assert unit.change.changed_with == SubmissionTypes.NORMAL

        assert suggestion.state == 'accepted'
        assert str(unit.target) == edited_target
        assert (Comment.objects
                       .for_model(suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 403
        assert suggestion.state == "pending"
        assert unit.target == ""
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
예제 #10
0
파일: unit.py 프로젝트: SafaAlfulaij/pootle
def test_submit_with_suggestion_and_comment(client, request_users, settings):
    """Tests translation can be applied after suggestion is accepted."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state='pending',
                               state=UNTRANSLATED)[0]
    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/' % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = 'This is a comment!'

    response = client.post(
        url,
        {
            'state': False,
            'target_f_0': edited_target,
            'suggestion': sugg.id,
            'comment': comment
        },
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    if check_permission('translate', response.wsgi_request):
        assert response.status_code == 200

        content = json.loads(response.content)

        assert content['newtargets'] == [edited_target]
        assert content['user_score'] == response.wsgi_request.user.public_score
        assert content['checks'] is None

        accepted_suggestion = Suggestion.objects.get(id=sugg.id)
        updated_unit = Unit.objects.get(id=unit.id)

        assert accepted_suggestion.state == 'accepted'
        assert str(updated_unit.target) == edited_target
        assert (Comment.objects
                       .for_model(accepted_suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 403
예제 #11
0
def test_accept_suggestion_with_comment(client, request_users, settings, system):
    """Tests suggestion can be accepted with a comment."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state__name='pending',
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state__name='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)
    comment = 'This is a comment!'
    response = client.post(
        url,
        {
            'comment': comment
        },
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    suggestion = Suggestion.objects.get(id=sugg.id)
    unit = Unit.objects.get(id=unit.id)
    if check_permission('review', response.wsgi_request):
        assert response.status_code == 200
        unit_source = unit.unit_source
        assert unit_source.created_by == system
        assert unit_source.created_with == SubmissionTypes.SYSTEM
        assert unit.change.submitted_by == suggestion.user
        assert unit.change.reviewed_by == user
        assert unit.change.changed_with == SubmissionTypes.WEB
        assert suggestion.state.name == 'accepted'
        assert suggestion.is_accepted
        assert str(unit.target) == str(suggestion.target)
        assert (Comment.objects
                       .for_model(suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 404
        assert suggestion.state.name == "pending"
        assert suggestion.is_pending
        assert unit.target == ""
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
예제 #12
0
def _get_suggestion_description(submission):
    user_url = reverse(
        'pootle-user-profile',
        args=[submission["suggestion__user__username"]])
    display_name = (
        submission["suggestion__user__full_name"].strip()
        if submission["suggestion__user__full_name"].strip()
        else submission["suggestion__user__username"].strip())
    params = {
        'author': format_html(u'<a href="{}">{}</a>',
                              user_url,
                              display_name)
    }
    Comment = get_comment_model()
    try:
        comment = Comment.objects.for_model(Suggestion).get(
            object_pk=submission["suggestion_id"],
        )
    except Comment.DoesNotExist:
        comment = None
    else:
        params.update({
            'comment': format_html(u'<span class="comment">{}</span>',
                                   comment.comment),
        })

    if comment:
        sugg_accepted_desc = _(
            u'Accepted suggestion from %(author)s with comment: %(comment)s',
            params
        )
        sugg_rejected_desc = _(
            u'Rejected suggestion from %(author)s with comment: %(comment)s',
            params
        )
    else:
        sugg_accepted_desc = _(u'Accepted suggestion from %(author)s', params)
        sugg_rejected_desc = _(u'Rejected suggestion from %(author)s', params)

    return {
        SubmissionTypes.SUGG_ADD: _(u'Added suggestion'),
        SubmissionTypes.SUGG_ACCEPT: sugg_accepted_desc,
        SubmissionTypes.SUGG_REJECT: sugg_rejected_desc,
    }.get(submission['type'], None)
예제 #13
0
def _get_suggestion_description(submission):
    user_url = reverse(
        'pootle-user-profile',
        args=[submission["suggestion__user__username"]])
    display_name = (
        submission["suggestion__user__full_name"].strip()
        if submission["suggestion__user__full_name"].strip()
        else submission["suggestion__user__username"].strip())
    params = {
        'author': format_html(u'<a href="{}">{}</a>',
                              user_url,
                              display_name)
    }
    Comment = get_comment_model()
    try:
        comment = Comment.objects.for_model(Suggestion).get(
            object_pk=submission["suggestion_id"],
        )
    except Comment.DoesNotExist:
        comment = None
    else:
        params.update({
            'comment': format_html(u'<span class="comment">{}</span>',
                                   comment.comment),
        })

    if comment:
        sugg_accepted_desc = _(
            u'Accepted suggestion from %(author)s with comment: %(comment)s',
            params
        )
        sugg_rejected_desc = _(
            u'Rejected suggestion from %(author)s with comment: %(comment)s',
            params
        )
    else:
        sugg_accepted_desc = _(u'Accepted suggestion from %(author)s', params)
        sugg_rejected_desc = _(u'Rejected suggestion from %(author)s', params)

    return {
        SubmissionTypes.SUGG_ADD: _(u'Added suggestion'),
        SubmissionTypes.SUGG_ACCEPT: sugg_accepted_desc,
        SubmissionTypes.SUGG_REJECT: sugg_rejected_desc,
    }.get(submission['type'], None)
예제 #14
0
파일: unit.py 프로젝트: ta2-1/pootle
def test_reject_suggestion_with_comment(client, request_users):
    """Tests suggestion can be rejected with a comment."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state__name='pending',
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state__name='pending')[0]
    comment = 'This is a comment!'
    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.delete(
        url,
        'comment=%s' % comment,
        HTTP_X_REQUESTED_WITH='XMLHttpRequest'
    )

    can_reject = (
        check_permission('review', response.wsgi_request)
        or sugg.user.id == user.id
    )
    suggestion = Suggestion.objects.get(id=sugg.id)
    if can_reject:
        assert response.status_code == 200
        assert suggestion.state.name == 'rejected'
        assert suggestion.is_rejected
        assert unit.target == ""
        # unit is untranslated so no change
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
        assert (Comment.objects
                       .for_model(suggestion)
                       .get().comment == comment)
    else:
        assert response.status_code == 404
        assert unit.target == ""
        assert suggestion.state.name == "pending"
        assert suggestion.is_pending
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
예제 #15
0
파일: unit.py 프로젝트: sshyran/zing
def test_submit_with_suggestion_and_comment(client, request_users):
    """Tests translation can be applied after suggestion is accepted."""
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state="pending",
                               state=UNTRANSLATED)[0]
    sugg = Suggestion.objects.filter(unit=unit, state="pending")[0]
    user = request_users["user"]
    if user.username != "nobody":
        client.force_login(user)

    url = "/xhr/units/%d/" % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = "This is a comment!"

    response = client.post(
        url,
        {
            "state": False,
            "target_f_0": edited_target,
            "suggestion": sugg.id,
            "comment": comment,
        },
        HTTP_X_REQUESTED_WITH="XMLHttpRequest",
    )

    if check_permission("translate", response.wsgi_request):
        assert response.status_code == 200
        accepted_suggestion = Suggestion.objects.get(id=sugg.id)
        updated_unit = Unit.objects.get(id=unit.id)

        assert accepted_suggestion.state == "accepted"
        assert str(updated_unit.target) == edited_target
        assert Comment.objects.for_model(
            accepted_suggestion).get().comment == comment
    else:
        assert response.status_code == 403
예제 #16
0
파일: timeline.py 프로젝트: arky/pootle
 def comment(self):
     comments = get_comment_model().objects.for_model(Suggestion)
     comments = comments.filter(
         object_pk=self.suggestion.id).values_list("comment", flat=True)
     if comments:
         return comments[0]
예제 #17
0
파일: unit.py 프로젝트: claudep/pootle
def test_submit_with_suggestion_and_comment(client, request_users,
                                            settings, system):
    """Tests translation can be applied after suggestion is accepted."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(
        suggestion__state__name='pending',
        state=UNTRANSLATED)[0]
    last_sub_pk = unit.submission_set.order_by(
        "id").values_list("id", flat=True).last() or 0
    sugg = Suggestion.objects.filter(unit=unit, state__name='pending')[0]
    user = request_users["user"]

    if user.username != "nobody":
        client.login(
            username=user.username,
            password=request_users["password"])

    url = '/xhr/units/%d/' % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = 'This is a comment!'
    qdict = QueryDict(mutable=True)
    qdict.update(
        {'state': False,
         'target_f_0': edited_target,
         'suggestion': sugg.id,
         'comment': comment})
    qdict._mutable = False
    response = client.post(
        url,
        qdict,
        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    suggestion = Suggestion.objects.get(id=sugg.id)
    unit = Unit.objects.get(id=unit.id)
    new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
    if check_permission('translate', response.wsgi_request):
        assert response.status_code == 200
        content = json.loads(response.content)
        assert content['newtargets'] == [edited_target]
        assert content['user_score'] == response.wsgi_request.user.public_score
        assert content['checks'] is None
        unit_source = unit.unit_source.get()
        assert unit_source.created_by == system
        assert unit_source.created_with == SubmissionTypes.SYSTEM
        assert unit.change.submitted_by == suggestion.user
        assert unit.change.reviewed_by == user
        assert unit.change.changed_with == SubmissionTypes.WEB

        assert suggestion.state.name == 'accepted'
        assert str(unit.target) == edited_target
        assert (Comment.objects
                       .for_model(suggestion)
                       .get().comment == comment)
        assert new_subs.count() == 2
        target_sub = new_subs[0]
        assert target_sub.old_value == ""
        assert target_sub.new_value == unit.target
        assert target_sub.field == SubmissionFields.TARGET
        assert target_sub.type == SubmissionTypes.WEB
        assert target_sub.submitter == unit.change.submitted_by
        assert target_sub.suggestion == suggestion
        assert target_sub.revision == unit.revision
        assert target_sub.creation_time == unit.change.reviewed_on

        state_sub = new_subs[1]
        assert state_sub.old_value == str(UNTRANSLATED)
        assert state_sub.new_value == str(unit.state)
        assert state_sub.suggestion == suggestion

        assert state_sub.field == SubmissionFields.STATE
        assert state_sub.type == SubmissionTypes.WEB

        assert state_sub.submitter == unit.change.submitted_by
        assert state_sub.revision == unit.revision
        assert state_sub.creation_time == unit.change.reviewed_on
    else:
        assert response.status_code == 403
        assert suggestion.state.name == "pending"
        assert unit.target == ""
        assert new_subs.count() == 0
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change
예제 #18
0
파일: timeline.py 프로젝트: ii0/pootle
 def comment(self):
     comments = get_comment_model().objects.for_model(Suggestion)
     comments = comments.filter(object_pk=self.suggestion.id).values_list(
         "comment", flat=True)
     if comments:
         return comments[0]
예제 #19
0
파일: unit.py 프로젝트: YESLTD/pootle
def test_submit_with_suggestion_and_comment(client, request_users, settings,
                                            system):
    """Tests translation can be applied after suggestion is accepted."""
    settings.POOTLE_CAPTCHA_ENABLED = False
    Comment = get_comment_model()
    unit = Unit.objects.filter(suggestion__state__name='pending',
                               state=UNTRANSLATED)[0]
    last_sub_pk = unit.submission_set.order_by("id").values_list(
        "id", flat=True).last() or 0
    sugg = Suggestion.objects.filter(unit=unit, state__name='pending')[0]
    user = request_users["user"]

    if user.username != "nobody":
        client.login(username=user.username,
                     password=request_users["password"])

    url = '/xhr/units/%d/' % unit.id
    edited_target = "Edited %s" % sugg.target_f
    comment = 'This is a comment!'
    qdict = QueryDict(mutable=True)
    qdict.update({
        'state': False,
        'target_f_0': edited_target,
        'suggestion': sugg.id,
        'comment': comment
    })
    qdict._mutable = False
    response = client.post(url, qdict, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    suggestion = Suggestion.objects.get(id=sugg.id)
    unit = Unit.objects.get(id=unit.id)
    new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
    if check_permission('translate', response.wsgi_request):
        assert response.status_code == 200
        content = json.loads(response.content)
        assert content['newtargets'] == [edited_target]
        assert content['user_score'] == response.wsgi_request.user.public_score
        assert content['checks'] is None
        unit_source = unit.unit_source
        assert unit_source.created_by == system
        assert unit_source.created_with == SubmissionTypes.SYSTEM
        assert unit.change.submitted_by == suggestion.user
        if user == suggestion.user:
            assert unit.change.reviewed_by is None
            assert unit.change.reviewed_on is None
        else:
            assert unit.change.reviewed_by == user
            assert unit.change.reviewed_on == unit.mtime
        assert unit.change.changed_with == SubmissionTypes.WEB

        assert suggestion.state.name == 'accepted'
        assert str(unit.target) == edited_target
        assert (Comment.objects.for_model(suggestion).get().comment == comment)
        assert new_subs.count() == 2
        target_sub = new_subs[0]
        assert target_sub.old_value == ""
        assert target_sub.new_value == unit.target
        assert target_sub.field == SubmissionFields.TARGET
        assert target_sub.type == SubmissionTypes.WEB
        assert target_sub.submitter == unit.change.submitted_by
        assert target_sub.suggestion == suggestion
        assert target_sub.revision == unit.revision
        assert target_sub.creation_time == unit.mtime

        state_sub = new_subs[1]
        assert state_sub.old_value == str(UNTRANSLATED)
        assert state_sub.new_value == str(unit.state)
        assert state_sub.suggestion == suggestion

        assert state_sub.field == SubmissionFields.STATE
        assert state_sub.type == SubmissionTypes.WEB

        assert state_sub.submitter == unit.change.submitted_by
        assert state_sub.revision == unit.revision
        assert state_sub.creation_time == unit.mtime
    else:
        assert response.status_code == 403
        assert suggestion.state.name == "pending"
        assert unit.target == ""
        assert new_subs.count() == 0
        with pytest.raises(UnitChange.DoesNotExist):
            unit.change