Пример #1
0
def test_put_volume(client: Client):
    res = client.put("/volumes/test", json={"password": "******"})
    data = res.get_json()

    assert res.status_code == 200
    assert data["name"] == "test"
    assert data["mounted"]
    assert len(data["_links"]) == 2
Пример #2
0
def test_drive_train_step(flask_app: Flask, client: Client):
    translate = 1
    rotate = 0
    data = {"translate": translate, "rotate": rotate}
    response = client.put("/drive_train/step", json=data)
    assert response.status_code == 200
    responese_data = response.json
    assert 1 == responese_data["left_motor_speed"]
    assert 1 == responese_data["right_motor_speed"]
Пример #3
0
def test_delete_volume(client: Client):
    res = client.put("/volumes/test", json={"password": "******"})
    href = get_href(res.get_json(), "self")

    res = client.delete(href)
    data = res.get_json()

    assert res.status_code == 200
    assert data["name"] == "test"
    assert not data["mounted"]
    assert len(data["_links"]) == 1
Пример #4
0
def test_get_files(client: Client):
    res = client.put("/volumes/test", json={"password": "******"})
    href = get_href(res.get_json(), "files")

    res = client.get(href)
    data = res.get_json()

    assert res.status_code == 200
    assert any(
        x["name"] == "bar.txt" and x["type"] == "file" and x["size"] == 11
        for x in data["contents"])
    assert any(x["name"] == "foo" and x["type"] == "directory"
               for x in data["contents"])
Пример #5
0
def put_json(client: Client, url: str, json_body: Union[dict, list],
             **kwargs) -> Response:
    """
    Send a PUT request to this URL.

    :param client: Flask test client.
    :param url: Relative server URL (starts with /).
    :param json_body: Python structure corresponding to the JSON to be sent.
    :return: Received response.
    """
    return client.put(url,
                      data=json.dumps(json_body),
                      content_type="application/json",
                      **kwargs)
Пример #6
0
def test_put_volume_incorrect_password(client: Client, password):
    res = client.put("/volumes/test", json={"password": password})
    data = res.get_json()

    assert res.status_code == 401