def remove_all_user_lists(username): 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) service = ListsService() service.delete_all_lists_for_a_user(username) span.log_kv({"status_code": 204, "result": ""}) return '', 204
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
def lists_for_specific_user(username): parent_span = create_parent_trace() with opentracing.tracer.start_span('playlist_get_all_user_lists', child_of=parent_span) as span: data_validator.validate_user_name(username) service = UsersService() result = service.retrieve_all_lists_for_user(username) span.log_kv({"status_code": 200, "result": result}) return jsonify(result), 200
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
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
def test_invalid_user_raises_error(self): sut = 'te' with pytest.raises(InvalidUsage): data_validator.validate_user_name(sut)
def test_valid_model_user_returns_none(self): sut = 'validuser' result = data_validator.validate_user_name(sut) assert result == None