Beispiel #1
0
def test_deliver_fields():
    schema = vases_schema
    data = {
        'id': 'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name': ' cElEstial ',
        'shape': 'round',
        'plants': [
            {'species': '  zzplant', 'quantity': 2},
            {'species': 'rubbertree', 'quantity': 1},
        ],
        'soil': {'color': '  BLACK  '}
    }
    assert util.deliver_fields(schema, data, 'private') == {
        'id': 'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name': ' cElEstial ',
        'shape': 'round',
        'plants': [
            {'species': '  zzplant', 'quantity': 2},
            {'species': 'rubbertree', 'quantity': 1},
        ],
        'soil': {'color': '  BLACK  '}
    }
    assert util.deliver_fields(schema, data) == {
        'id': 'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name': ' cElEstial ',
        'shape': 'round',
        'plants': [
            {'species': '  zzplant'},
            {'species': 'rubbertree'},
        ],
        'soil': {}
    }
Beispiel #2
0
def test_deliver_fields():
    schema = vases_schema
    data = {
        'id':
        'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name':
        ' cElEstial ',
        'shape':
        'round',
        'plants': [
            {
                'species': '  zzplant',
                'quantity': 2
            },
            {
                'species': 'rubbertree',
                'quantity': 1
            },
        ],
        'soil': {
            'color': '  BLACK  '
        }
    }
    assert util.deliver_fields(schema, data, 'private') == {
        'id':
        'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name':
        ' cElEstial ',
        'shape':
        'round',
        'plants': [
            {
                'species': '  zzplant',
                'quantity': 2
            },
            {
                'species': 'rubbertree',
                'quantity': 1
            },
        ],
        'soil': {
            'color': '  BLACK  '
        }
    }
    assert util.deliver_fields(schema, data) == {
        'id': 'ZdhhJQ9U9YJaanmfMEpm05qc',
        'name': ' cElEstial ',
        'shape': 'round',
        'plants': [
            {
                'species': '  zzplant'
            },
            {
                'species': 'rubbertree'
            },
        ],
        'soil': {}
    }
Beispiel #3
0
def deliver_topic(data, access=None):
    """
    Prepare user data for JSON response.
    """

    schema = topic_schema
    return deliver_fields(schema, data, access)
Beispiel #4
0
def deliver_response(data, access=None):
    """
  Prepare a response for JSON output.
  """

    schema = response_schema
    return deliver_fields(schema, data, access)
Beispiel #5
0
def deliver_follow(data, access=None):
    """
    Prepare a follow for JSON output.
    """

    schema = follow_schema
    return deliver_fields(schema, data, access)
Beispiel #6
0
def deliver_post(data, access=None):
    """
  Prepare post data for JSON response.
  """

    schema = get_post_schema(data)
    return deliver_fields(schema, data, access)
Beispiel #7
0
def deliver_user(data, access=None):
    """
    Prepare user data for JSON response.
    """

    schema = user_schema
    return deliver_fields(schema, data, access)
Beispiel #8
0
def deliver_notice(notice, access=None):
    """
    Add the notice body to the notice before delivering.
    """

    schema = notice_schema
    notice = deepcopy(notice)
    notice['body'] = get_notice_body(notice)
    return deliver_fields(schema, notice, access)
Beispiel #9
0
def deliver_notice(notice, access=None):
    """
    Add the notice body to the notice before delivering.
    """

    schema = notice_schema
    notice = deepcopy(notice)
    notice['body'] = get_notice_body(notice)
    return deliver_fields(schema, notice, access)