1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00
mealie/tests/integration_tests/user_tests/test_user_images.py
Hayden 791aa8c610
feat(backend): refactor/fix group management for admins (#838)
* fix(frontend): 🐛 update dialog implementation to simplify state management

* test(backend):  refactor test fixtures + admin group tests

* chore(backend): 🔨 add launcher.json for python debugging (tests)

* fix typing

* feat(backend):  refactor/fix group management for admins

* feat(frontend):  add/fix admin group management

* add LDAP checker

Co-authored-by: hay-kot <hay-kot@pm.me>
2021-11-25 14:17:02 -09:00

30 lines
942 B
Python

from pathlib import Path
from fastapi.testclient import TestClient
from mealie.core.config import get_app_dirs
app_dirs = get_app_dirs()
from tests.utils.app_routes import AppRoutes
def test_update_user_image(
api_client: TestClient, api_routes: AppRoutes, test_image_jpg: Path, test_image_png: Path, admin_token
):
response = api_client.post(
api_routes.users_id_image(2), files={"profile_image": test_image_jpg.open("rb")}, headers=admin_token
)
assert response.status_code == 200
response = api_client.post(
api_routes.users_id_image(2), files={"profile_image": test_image_png.open("rb")}, headers=admin_token
)
assert response.status_code == 200
directory = app_dirs.USER_DIR.joinpath("2")
assert directory.joinpath("profile_image.png").is_file()
# Old profile images are removed
assert 1 == len([file for file in directory.glob("profile_image.*") if file.is_file()])