1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

fix: Prevent Bad Cookbook Names (#4364)

This commit is contained in:
Michael Genson 2024-10-15 12:54:58 -05:00 committed by GitHub
parent 1af2473a72
commit 6d89fe37ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -62,6 +62,22 @@ def test_create_cookbook(api_client: TestClient, unique_user: TestUser):
assert response.status_code == 201
@pytest.mark.parametrize("name_input", ["", " ", "@"])
def test_create_cookbook_bad_name(api_client: TestClient, unique_user: TestUser, name_input: str):
data = {
"name": name_input,
"slug": name_input,
"description": "",
"position": 0,
"categories": [],
"group_id": str(unique_user.group_id),
"household_id": str(unique_user.household_id),
}
response = api_client.post(api_routes.households_cookbooks, json=data, headers=unique_user.token)
assert response.status_code == 422
def test_read_cookbook(api_client: TestClient, unique_user: TestUser, cookbooks: list[TestCookbook]):
sample = random.choice(cookbooks)
response = api_client.get(api_routes.households_cookbooks_item_id(sample.id), headers=unique_user.token)