def test_crud_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    add_ecriture_droit(client, epci_id=fiche_action["epci_id"])

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

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

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

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

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

    # DELETE /v2/fiche_action/epci_id/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["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"]
    assert response.json()["meta"] == indicateur_personnalise["meta"]

    # 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 post_with_droits(
    client: TestClient,
    epci_id: str,
    post_json: dict,
    post_path: str,
) -> Response:
    add_ecriture_droit(client, epci_id=epci_id)
    return client.post(post_path, json=post_json, headers=auth_headers())
Example #4
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
def test_add_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    assert AUTH_DISABLED_DUMMY_USER

    # POST /v2/utilisateur_droits
    response = add_ecriture_droit(client, droits["ademe_user_id"],
                                  droits["epci_id"], droits["ecriture"])
    assert response.status_code == 200
    assert response.json()["epci_id"] == droits["epci_id"]
Example #6
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"]
Example #7
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"]
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"]
Example #9
0
def test_update_meta(client: TestClient):
    add_ecriture_droit(client, epci_id=meta["epci_id"])

    new_data = {
        "meta": {
            "commentaire": "hello"
        },
    }

    new_meta = {**meta, **new_data}

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

    assert response.status_code == 200
    assert response.json()["action_id"] == meta["action_id"]
    assert response.json()["meta"] == new_meta["meta"]

    response = client.get(list_path)
    assert response.status_code == 200
    assert len(response.json()) == 1
    assert response.json()[0]["action_id"] == meta["action_id"]
    assert response.json()[0]["meta"] == new_meta["meta"]
def test_crud_item(client: TestClient, event_loop: asyncio.AbstractEventLoop):
    add_ecriture_droit(client,
                       epci_id=indicateur_referentiel_commentaire["epci_id"])

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

    # GET /v2/indicateur_referentiel_commentaire/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_referentiel_commentaire["indicateur_id"])

    # GET /v2/indicateur_referentiel_commentaire/epci_id/indicateur_id
    response = client.get(item_path)
    assert response.status_code == 200
    assert (response.json()["indicateur_id"] ==
            indicateur_referentiel_commentaire["indicateur_id"])
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"]