예제 #1
0
def test_create_list_not_authenticated(client):
    url = url_for("graphql")
    res = client.post(url,
                      json={
                          "query": create_list_query,
                          "variables": {
                              "name": "foo",
                              "description": "bar"
                          }
                      })

    assert res.status_code == HTTPStatus.OK

    res = res.json
    assert not res["data"]["createList"]
    assert List.count() == 0
예제 #2
0
def test_delete_list_not_authenticated(client, list_):
    url = url_for("graphql")

    list_id = to_global_id("TypeList", list_.id)
    res = client.post(url,
                      json={
                          "query": delete_list_query,
                          "variables": {
                              "id": list_id
                          }
                      })

    assert res.status_code == HTTPStatus.OK

    res = res.json
    assert not res["data"]["deleteList"]

    assert List.count() == 1
예제 #3
0
def test_delete_list(client, list_, access_token):
    url = url_for("graphql")

    list_id = to_global_id("TypeList", list_.id)
    res = client.post(url,
                      headers={"Authorization": f"Bearer {access_token}"},
                      json={
                          "query": delete_list_query,
                          "variables": {
                              "id": list_id
                          }
                      })

    assert res.status_code == HTTPStatus.OK

    res = res.json
    assert res["data"]["deleteList"]["ok"]

    assert List.count() == 0
예제 #4
0
def test_create_list_invalid(client, access_token):
    url = url_for("graphql")
    res = client.post(
        url,
        headers={"Authorization": f"Bearer {access_token}"},
        json={
            "query": create_list_query,
            "variables": {
                "name": "",
                "description": "bar"
            }
        },
    )

    assert res.status_code == HTTPStatus.OK

    res = res.json
    assert not res["data"]["createList"]
    assert List.count() == 0