mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
group tests
This commit is contained in:
parent
f386ee8254
commit
11c94f2987
2 changed files with 52 additions and 11 deletions
File diff suppressed because one or more lines are too long
|
@ -1,22 +1,63 @@
|
|||
import json
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from tests.app_routes import AppRoutes
|
||||
|
||||
|
||||
def test_create_group(api_client: TestClient, api_routes: AppRoutes):
|
||||
assert False is True
|
||||
@pytest.fixture
|
||||
def group_data():
|
||||
return {"name": "Test Group"}
|
||||
|
||||
|
||||
def test_get_self_group(api_client: TestClient, api_routes: AppRoutes):
|
||||
assert False is True
|
||||
def test_create_group(api_client: TestClient, api_routes: AppRoutes, token):
|
||||
response = api_client.post(api_routes.groups, json={"name": "Test Group"}, headers=token)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
assert json.loads(response.content) == {
|
||||
"snackbar": {"text": "User Group Created", "type": "success"},
|
||||
"created": True,
|
||||
}
|
||||
|
||||
|
||||
def test_update_group(api_client: TestClient, api_routes: AppRoutes):
|
||||
assert False is True
|
||||
def test_get_self_group(api_client: TestClient, api_routes: AppRoutes, token):
|
||||
response = api_client.get(api_routes.groups, headers=token)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(json.loads(response.text)) >= 2
|
||||
|
||||
|
||||
def test_block_delete(api_client: TestClient, api_routes: AppRoutes):
|
||||
assert False is True
|
||||
def test_update_group(api_client: TestClient, api_routes: AppRoutes, token):
|
||||
new_data = {
|
||||
"name": "New Group Name",
|
||||
"id": 2,
|
||||
"categories": [],
|
||||
"webhookUrls": [],
|
||||
"webhookTime": "00:00",
|
||||
"webhookEnable": False,
|
||||
"users": [],
|
||||
"mealplans": [],
|
||||
}
|
||||
# Test Update
|
||||
response = api_client.put(api_routes.groups_id(2), json=new_data, headers=token)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.text) == {"snackbar": {"text": "Group Settings Updated", "type": "success"}}
|
||||
|
||||
# Validate Changes
|
||||
response = api_client.get(api_routes.groups, headers=token)
|
||||
all_groups = json.loads(response.text)
|
||||
id_2 = filter(lambda x: x["id"] == 2, all_groups)
|
||||
assert next(id_2) == new_data
|
||||
|
||||
|
||||
def test_delete_group(api_client: TestClient, api_routes: AppRoutes):
|
||||
assert False is True
|
||||
def test_block_delete(api_client: TestClient, api_routes: AppRoutes, token):
|
||||
response = api_client.delete(api_routes.groups_id(1), headers=token)
|
||||
|
||||
assert json.loads(response.text) == {"snackbar": {"text": "Cannot delete default group", "type": "error"}}
|
||||
|
||||
|
||||
def test_delete_group(api_client: TestClient, api_routes: AppRoutes, token):
|
||||
response = api_client.delete(api_routes.groups_id(2), headers=token)
|
||||
|
||||
assert json.loads(response.text) is None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue