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
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
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
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
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
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
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