Esempio n. 1
0
def test_transform_annotation(ann, nipsa, has_nipsa):
    event = FakeEvent(annotation_dict=ann)
    has_nipsa.return_value = nipsa
    subscribers.transform_annotation(event)
    if nipsa:
        assert ann["nipsa"] is True
    else:
        assert "nipsa" not in ann
Esempio n. 2
0
def test_transform_annotation(ann, nipsa, has_nipsa):
    event = FakeEvent(annotation=ann)
    has_nipsa.return_value = nipsa
    subscribers.transform_annotation(event)
    if nipsa:
        assert ann["nipsa"] is True
    else:
        assert "nipsa" not in ann
Esempio n. 3
0
def test_transform_annotation(ann, flagged, nipsa_service, pyramid_request):
    nipsa_service.is_flagged.return_value = flagged
    event = FakeEvent(request=pyramid_request, annotation_dict=ann)

    subscribers.transform_annotation(event)

    if flagged:
        assert ann["nipsa"] is True
    else:
        assert "nipsa" not in ann
Esempio n. 4
0
def test_transform_annotation(ann, flagged, nipsa_service, pyramid_request):
    nipsa_service.is_flagged.return_value = flagged
    event = FakeEvent(request=pyramid_request,
                      annotation_dict=ann)

    subscribers.transform_annotation(event)

    if flagged:
        assert ann["nipsa"] is True
    else:
        assert "nipsa" not in ann
Esempio n. 5
0
    def test_with_moderated_annotation(self, ann, moderated, moderation_service, pyramid_request):
        moderation_service.hidden.return_value = moderated
        event = FakeEvent(request=pyramid_request,
                          annotation=ann,
                          annotation_dict=ann.data)

        subscribers.transform_annotation(event)

        if moderated:
            assert ann.data['nipsa'] is True
        else:
            assert 'nipsa' not in ann.data
Esempio n. 6
0
    def test_with_user_nipsa(self, ann, flagged, nipsa_service, pyramid_request):
        nipsa_service.is_flagged.return_value = flagged
        event = FakeEvent(request=pyramid_request,
                          annotation=ann,
                          annotation_dict=ann.data)

        subscribers.transform_annotation(event)

        if flagged:
            assert ann.data['nipsa'] is True
        else:
            assert 'nipsa' not in ann.data
Esempio n. 7
0
    def test_with_user_nipsa(self, ann, flagged, nipsa_service,
                             pyramid_request):
        nipsa_service.is_flagged.return_value = flagged
        event = FakeEvent(request=pyramid_request,
                          annotation=ann,
                          annotation_dict=ann.data)

        subscribers.transform_annotation(event)

        if flagged:
            assert ann.data['nipsa'] is True
        else:
            assert 'nipsa' not in ann.data
Esempio n. 8
0
    def test_with_moderated_annotation(self, ann, moderated,
                                       moderation_service, pyramid_request):
        moderation_service.hidden.return_value = moderated
        event = FakeEvent(request=pyramid_request,
                          annotation=ann,
                          annotation_dict=ann.data)

        subscribers.transform_annotation(event)

        if moderated:
            assert "nipsa" not in ann.data
        else:
            assert "nipsa" not in ann.data
Esempio n. 9
0
    def test_with_moderated_annotation(self, ann, moderated,
                                       enable_hidden_filter,
                                       moderation_service, pyramid_request):
        moderation_service.hidden.return_value = moderated
        event = FakeEvent(request=pyramid_request,
                          annotation=ann,
                          annotation_dict=ann.data)
        pyramid_request.feature.flags[
            'replace_nipsa_with_hidden_filter'] = enable_hidden_filter

        subscribers.transform_annotation(event)

        if enable_hidden_filter:
            if moderated:
                assert 'nipsa' not in ann.data
            else:
                assert 'nipsa' not in ann.data
        else:
            if moderated:
                assert ann.data['nipsa'] is True
            else:
                assert 'nipsa' not in ann.data