예제 #1
0
def test_crud_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    add_ecriture_droit(client, epci_id=indicateur_personnalise["epci_id"])

    # POST /epci_id/v2/indicateur_personnalise
    response = client.post(
        post_path, json=indicateur_personnalise, headers=auth_headers()
    )
    assert response.status_code == 200
    assert response.json()["uid"] == indicateur_personnalise["uid"]

    # GET /epci_id/v2/indicateur_personnalise/all
    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["uid"] == indicateur_personnalise["uid"]

    # GET /epci_id/v2/indicateur_personnalise/uid
    response = client.get(item_path)
    assert response.status_code == 200
    assert response.json()["uid"] == indicateur_personnalise["uid"]

    # DELETE /epci_id/v2/indicateur_personnalise/uid
    response = client.delete(item_path, headers=auth_headers())
    assert response.status_code == 200

    # 404
    # GET /epci_id/v2/indicateur_personnalise/uid
    response = client.get(item_path)
    assert response.status_code == 404

    # DELETE /epci_id/v2/indicateur_personnalise/uid
    response = client.delete(item_path, headers=auth_headers())
    assert response.status_code == 404
def test_crud_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    add_ecriture_droit(client,
                       epci_id=indicateur_personnalise_value["epci_id"])

    # POST /v2/indicateur_personnalise_value/epci_id
    response = client.post(post_path,
                           json=indicateur_personnalise_value,
                           headers=auth_headers())
    assert response.status_code == 200
    assert (response.json()["indicateur_id"] ==
            indicateur_personnalise_value["indicateur_id"])

    # GET /v2/indicateur_personnalise_value/epci_id/all
    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert (response.json()[0]["indicateur_id"] ==
            indicateur_personnalise_value["indicateur_id"])

    # GET /v2/indicateur_personnalise_value/epci_id/indicateur_id
    response = client.get(yearly_list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert (response.json()[0]["indicateur_id"] ==
            indicateur_personnalise_value["indicateur_id"])

    # GET /v2/indicateur_personnalise_value/epci_id/indicateur_id/year
    response = client.get(item_path)
    assert response.status_code == 200
    assert (response.json()["indicateur_id"] ==
            indicateur_personnalise_value["indicateur_id"])
예제 #3
0
def test_create_mismatched_status(client: TestClient):
    add_ecriture_droit(client, epci_id=status["epci_id"])
    mismatched_data = {
        "epci_id": "mismatch-epci-id",
    }
    mismatched_status = {**status, **mismatched_data}

    post_path = f"{path}/{status['epci_id']}"
    response = client.post(post_path,
                           headers=auth_headers(),
                           json=mismatched_status)

    assert response.status_code == 400
예제 #4
0
def test_crud_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    add_ecriture_droit(client, epci_id=status["epci_id"])

    # POST /v2/action_status/epci_id
    response = client.post(post_path, json=status, headers=auth_headers())
    assert response.status_code == 200
    assert response.json()["action_id"] == status["action_id"]

    # GET /v2/action_status/epci_id/all
    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["action_id"] == status["action_id"]

    # GET /v2/action_status/epci_id/action_id
    response = client.get(item_path)
    assert response.status_code == 200
    assert response.json()["action_id"] == status["action_id"]
예제 #5
0
def test_update(client: TestClient):
    add_ecriture_droit(client, epci_id=epci["uid"])

    new_data = {
        "nom": "Blue Kingdom",
    }

    updated_epci = {**epci, **new_data}

    response = client.post(post_path, headers=auth_headers(), json=updated_epci)

    assert response.status_code == 200
    assert response.json()["uid"] == epci["uid"]
    assert response.json()["nom"] == new_data["nom"]

    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["uid"] == epci["uid"]
    assert response.json()[0]["nom"] == new_data["nom"]
예제 #6
0
def test_update_status(client: TestClient):
    add_ecriture_droit(client, epci_id=status["epci_id"])

    new_data = {
        "avancement": "programmee",
    }

    new_status = {**status, **new_data}

    post_path = f"{path}/{new_status['epci_id']}"
    response = client.post(post_path, headers=auth_headers(), json=new_status)

    assert response.status_code == 200
    assert response.json()["action_id"] == status["action_id"]
    assert response.json()["avancement"] == new_status["avancement"]

    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["action_id"] == status["action_id"]
    assert response.json()[0]["avancement"] == new_status["avancement"]
예제 #7
0
def test_update_indicateur_personnalise(client: TestClient):
    new_data = {
        "nom": "Cheshire Cat",
    }

    existing_indicateur_personnalise = {**indicateur_personnalise, **new_data}

    add_ecriture_droit(client, epci_id=existing_indicateur_personnalise["epci_id"])

    post_path = f"{path}/{existing_indicateur_personnalise['epci_id']}"
    response = client.post(
        post_path, json=existing_indicateur_personnalise, headers=auth_headers()
    )

    assert response.status_code == 200
    assert response.json()["uid"] == existing_indicateur_personnalise["uid"]
    assert response.json()["nom"] == existing_indicateur_personnalise["nom"]

    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["uid"] == existing_indicateur_personnalise["uid"]
    assert response.json()[0]["nom"] == existing_indicateur_personnalise["nom"]