コード例 #1
0
ファイル: transform_test.py プロジェクト: ackermann/h
def test_set_group_permissions_sets_read_permissions_for_group_annotations():
    annotation = {
        'user': '******',
        'group': 'xyzabc',
        'permissions': {
            'read': ['group:__world__']
        }
    }

    transform.set_group_permissions(annotation)

    assert annotation['permissions']['read'] == ['group:xyzabc']
コード例 #2
0
ファイル: transform_test.py プロジェクト: badgettrg/Webmarks
def test_set_group_permissions_sets_read_permissions_for_group_annotations():
    annotation = {
        'user': '******',
        'group': 'xyzabc',
        'permissions': {
            'read': ['group:__world__']
        }
    }

    transform.set_group_permissions(annotation)

    assert annotation['permissions']['read'] == ['group:xyzabc']
コード例 #3
0
ファイル: transform_test.py プロジェクト: badgettrg/Webmarks
def test_set_group_permissions_does_not_modify_non_group_annotations():
    original_annotation = {
        'user': '******',
        'permissions': {
            'read': ['acct:[email protected]']
        },
        'group': '__world__'
    }
    annotation_to_be_modified = copy.deepcopy(original_annotation)

    transform.set_group_permissions(annotation_to_be_modified)

    assert annotation_to_be_modified == original_annotation
コード例 #4
0
ファイル: transform_test.py プロジェクト: ackermann/h
def test_set_group_permissions_does_not_modify_non_group_annotations():
    original_annotation = {
        'user': '******',
        'permissions': {
            'read': ['acct:[email protected]']
        },
        'group': '__world__'
    }
    annotation_to_be_modified = copy.deepcopy(original_annotation)

    transform.set_group_permissions(annotation_to_be_modified)

    assert annotation_to_be_modified == original_annotation
コード例 #5
0
ファイル: transform_test.py プロジェクト: badgettrg/Webmarks
def test_set_group_permissions_does_not_modify_annotations_with_no_permissions():
    annotations = [{
        'user': '******',
    },
    {
        'user': '******',
        'group': 'xyzabc',
    }]

    for ann in annotations:
        before = copy.deepcopy(ann)
        transform.set_group_permissions(ann)

        assert ann == before
コード例 #6
0
ファイル: transform_test.py プロジェクト: ackermann/h
def test_set_group_permissions_does_not_modify_annotations_with_no_permissions():
    annotations = [{
        'user': '******',
    },
    {
        'user': '******',
        'group': 'xyzabc',
    }]

    for ann in annotations:
        before = copy.deepcopy(ann)
        transform.set_group_permissions(ann)

        assert ann == before
コード例 #7
0
ファイル: storage.py プロジェクト: hashin/h
def _prepare(request, annotation):
    """
    Prepare the given annotation for storage.

    Scan the passed annotation for any target URIs or document metadata URIs
    and add normalized versions of these to the document.
    """
    fetcher = partial(fetch_annotation, request)
    transform.set_group_if_reply(annotation, fetcher=fetcher)
    transform.insert_group_if_none(annotation)
    transform.set_group_permissions(annotation)

    # FIXME: Remove this in a month or so, when all our clients have been
    # updated. -N 2015-09-25
    transform.fix_old_style_comments(annotation)

    # FIXME: When this becomes simply part of a search indexing operation, this
    # should probably not mutate its argument.
    transform.normalize_annotation_target_uris(annotation)

    # Fire an AnnotationBeforeSaveEvent so subscribers who wish to modify an
    # annotation before save can do so.
    event = AnnotationBeforeSaveEvent(request, annotation)
    request.registry.notify(event)
コード例 #8
0
def _prepare(request, annotation):
    """
    Prepare the given annotation for storage.

    Scan the passed annotation for any target URIs or document metadata URIs
    and add normalized versions of these to the document.
    """
    fetcher = partial(fetch_annotation, request)
    transform.set_group_if_reply(annotation, fetcher=fetcher)
    transform.insert_group_if_none(annotation)
    transform.set_group_permissions(annotation)

    # FIXME: Remove this in a month or so, when all our clients have been
    # updated. -N 2015-09-25
    transform.fix_old_style_comments(annotation)

    # FIXME: When this becomes simply part of a search indexing operation, this
    # should probably not mutate its argument.
    transform.normalize_annotation_target_uris(annotation)

    # Fire an AnnotationBeforeSaveEvent so subscribers who wish to modify an
    # annotation before save can do so.
    event = AnnotationBeforeSaveEvent(request, annotation)
    request.registry.notify(event)