# ruff: noqa: E501 """794-1 M01 저장 길 — 시스템 관리자만(로직 줄 식 고침 `/save` 시험은 855 L3 ⓐ 에서 걷음 — /save 는 기초 머리만 씀 · 셈 = 문서 저장). - 시트 서버 길(`/logic/sheet` · `/check`)은 화면 0 이라 853-1 에 걷음 — 남은 것은 살아 있는 `/save` · `/calc` - 서버(사본 폴더): 시스템 관리자가 아니면 403 """ from __future__ import annotations import shutil from pathlib import Path import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from common_util.common_util_auth import require_system_admin, verify_session from M01_MasterData import M01_MasterData_Router as m01_router from M01_MasterData import M01_MasterData_Store as store REAL = store.FOLDER # ── 서버 ───────────────────────────────────────────────────────────── @pytest.fixture def folder(tmp_path: Path, monkeypatch) -> Path: master = tmp_path / "master" master.mkdir() for path in REAL.glob("*.json"): shutil.copy(path, master / path.name) shutil.copytree(REAL / "기계", master / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", master) return master def test_시스템_관리자가_아니면_403(folder: Path) -> None: app = FastAPI() app.include_router( m01_router.router, dependencies=[Depends(verify_session), Depends(require_system_admin)] ) app.dependency_overrides[verify_session] = lambda: {"role": "USER", "company_id": 1} client = TestClient(app) assert client.post("/api/m01/save", json={"files": []}).status_code == 403