Skip to content

Commit

Permalink
Revert "remove test"
Browse files Browse the repository at this point in the history
This reverts commit 876ed2c.
  • Loading branch information
victorgarcia98 committed Oct 7, 2023
1 parent d71a574 commit 14bc970
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions flexmeasures/api/v3_0/tests/test_assets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,26 @@ def test_alter_an_asset_with_json_attributes(
assert asset_edit_response.status_code == 200


@pytest.mark.parametrize("requesting_user", ["test_admin_user@seita.nl"], indirect=True)
def test_post_an_asset_with_existing_name(client, setup_api_test_data, requesting_user):
"""Catch DB error (Unique key violated) correctly"""
with AccountContext("Test Prosumer Account") as prosumer:
prosumer_id = prosumer.id
existing_asset = prosumer.generic_assets[0]
post_data = get_asset_post_data()
post_data["name"] = existing_asset.name
post_data["account_id"] = prosumer_id
asset_creation_response = client.post(
url_for("AssetAPI:post"),
json=post_data,
)
print(f"Creation Response: {asset_creation_response.json}")
assert asset_creation_response.status_code == 422
assert (
"already exists" in asset_creation_response.json["message"]["json"]["name"][0]
)


@pytest.mark.parametrize(
"requesting_user", ["test_prosumer_user_2@seita.nl"], indirect=True
)
Expand Down

0 comments on commit 14bc970

Please sign in to comment.