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': {} }
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': {} }
def deliver_topic(data, access=None): """ Prepare user data for JSON response. """ schema = topic_schema return deliver_fields(schema, data, access)
def deliver_response(data, access=None): """ Prepare a response for JSON output. """ schema = response_schema return deliver_fields(schema, data, access)
def deliver_follow(data, access=None): """ Prepare a follow for JSON output. """ schema = follow_schema return deliver_fields(schema, data, access)
def deliver_post(data, access=None): """ Prepare post data for JSON response. """ schema = get_post_schema(data) return deliver_fields(schema, data, access)
def deliver_user(data, access=None): """ Prepare user data for JSON response. """ schema = user_schema return deliver_fields(schema, data, access)
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)