예제 #1
0
 def validate_misc_fields_in_json(self, json_body):
     data_validator.validate_beverages(json_body['beverages'])
     data_validator.validate_display_name(json_body['displayName'])
     if 'imageUrl' in json_body:
         data_validator.validate_image_url(json_body['imageUrl'])
     if 'list' in json_body:
         data_validator.validate_play_list(json_body['list'])
예제 #2
0
def front_page_list(playlist):
    parent_span = create_parent_trace()
    with opentracing.tracer.start_span('playlist_frontpage',
                                       child_of=parent_span) as span:
        data_validator.validate_play_list(playlist)
        service = FrontPageService()
        result = service.retrieve_front_page_list(playlist)
        span.log_kv({"status_code": 200, "result": result})
        return jsonify({"result": result}), 200
예제 #3
0
def specific_list_for_specific_user(username, playlist):
    parent_span = create_parent_trace()
    with opentracing.tracer.start_span('playlist_list_get',
                                       child_of=parent_span) as span:
        data_validator.validate_user_name(username)
        data_validator.validate_play_list(playlist)
        service = ListsService()
        result = service.get_specific_user_list(username, playlist)
        return jsonify({"result": result}), 200
예제 #4
0
def remove_user_list(username, playlist):
    parent_span = create_parent_trace()
    with opentracing.tracer.start_span('playlist_list_delete',
                                       child_of=parent_span) as span:
        data_validator.validate_user_name(username)
        data_validator.validate_play_list(playlist)
        service = ListsService()
        service.delete_user_list(username, playlist)
        span.log_kv({"status_code": 204, "result": ""})
        return '', 204
예제 #5
0
def update_user_list(username, playlist):
    parent_span = create_parent_trace()
    with opentracing.tracer.start_span('playlist_list_update',
                                       child_of=parent_span) as span:
        json_body = request.json
        data_validator.validate_user_name(username)
        data_validator.validate_play_list(playlist)
        service = ListsService()
        service.update_list(username.lower(), playlist, json_body)
        span.log_kv({"status_code": 204, "result": ""})
        return '', 204
예제 #6
0
def create_new_list(username, playlist):
    parent_span = create_parent_trace()
    json_body = request.json
    with opentracing.tracer.start_span('playlist_list_post',
                                       child_of=parent_span) as span:
        data_validator.validate_user_name(username)
        data_validator.validate_play_list(playlist)
        service = ListsService()
        service.post_new_list(json_body, username, playlist)
        span.log_kv({"status_code": 201, "result": ""})
        return '', 201
예제 #7
0
 def test_invalid_list_raises_error(self):
     sut = 't'
     with pytest.raises(InvalidUsage):
         data_validator.validate_play_list(sut)
예제 #8
0
 def test_valid_model_list_returns_none(self):
     sut = 'validlist'
     result = data_validator.validate_play_list(sut)
     assert result == None