Beispiel #1
0
def post(app, client, payload=None):
    if payload is None:
        payload = default_payload_post

    # post a training first
    response = post_training(app, client)
    payload["training_id"] = json.loads(response.get_data())

    # post a bike first
    response = post_bike(app, client)
    payload["bike_id"] = json.loads(response.get_data())

    # post a setup first
    response = post_setup(app, client)
    payload["setup_id"] = json.loads(response.get_data())

    response = client.post(
        "/api/session",
        data=json.dumps(payload),
        content_type='application/json',
        headers={"apikey": app.config['FLASK_RESTPLUS_API_KEY']})
    payload.pop("training_id")
    payload.pop("bike_id")
    payload.pop("setup_id")

    return response
Beispiel #2
0
def post(app, client, payload=None):
    if payload is None:
        payload = default_payload_post

    # post a bike first
    response = post_bike(app, client)
    payload["bike_id"] = json.loads(response.get_data())

    try:
        response = client.post("/api/maintenance", data=json.dumps(payload), content_type='application/json',
                               headers={"apikey": app.config['FLASK_RESTPLUS_API_KEY']})
    except IntegrityError:
        # maintenance name already exists
        payload["name"] = datetime.now().strftime("%m%d%Y%H%M%S.%f")
        response = client.post("/api/maintenance", data=json.dumps(payload), content_type='application/json',
                               headers={"apikey": app.config['FLASK_RESTPLUS_API_KEY']})
    payload.pop("bike_id")

    return response
Beispiel #3
0
def post(app, client, payload=None):
    if payload is None:
        payload = default_payload_post

    # post a bike first
    response = post_bike(app, client)
    payload["bike_id"] = json.loads(response.get_data())

    # post a maintenance first
    response = post_maintenance(app, client)
    payload["maintenance_id"] = json.loads(response.get_data())

    response = client.post(
        "/api/history",
        data=json.dumps(payload),
        content_type='application/json',
        headers={"apikey": app.config['FLASK_RESTPLUS_API_KEY']})
    payload.pop("bike_id")
    payload.pop("maintenance_id")

    return response