a281bebedf
소유자는 owner_email 로만 권한을 받고 멤버 행이 없어 멤버 목록에 보이지 않았다. 프로젝트를 만들 때·소유자를 바꿀 때 소유자를 멤버로 넣고, 소유자는 멤버에서 뺄 수 없게 한다(화면은 이미 체크 잠금). 기존 프로젝트는 마이그레이션 031 로 소유자 멤버 행을 채운다(멱등). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""소유자 = 멤버(2026-10-20) — 소유자는 멤버에서 뺄 수 없다. DB 없이 가짜 저장소로."""
|
|
import importlib
|
|
import unittest
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
api = importlib.import_module("app.modules.project.router")
|
|
ME = {"email": "pro@test.local", "role": "pro"}
|
|
|
|
|
|
class RemoveOwnerTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.st = MagicMock()
|
|
self.st.get_project.return_value = {"id": 7, "owner_email": "Owner@Test.local"}
|
|
app = FastAPI()
|
|
app.include_router(api.router)
|
|
self.client = TestClient(app, raise_server_exceptions=False)
|
|
for p in (patch.object(api, "_require_pro", return_value=ME), patch.object(api, "_db_or_503", return_value=self.st),
|
|
patch.object(api, "_require_manage", return_value=None)):
|
|
p.start()
|
|
self.addCleanup(p.stop)
|
|
|
|
def test_owner_cannot_be_removed(self):
|
|
r = self.client.delete("/project/api/projects/7/members/owner@test.local")
|
|
self.assertEqual(r.status_code, 400, r.text)
|
|
self.assertIn("소유자", r.json()["detail"])
|
|
self.st.remove_member.assert_not_called()
|
|
|
|
def test_other_member_can_be_removed(self):
|
|
r = self.client.delete("/project/api/projects/7/members/bob@test.local")
|
|
self.assertEqual(r.status_code, 200, r.text)
|
|
self.st.remove_member.assert_called_once_with(project_id=7, user_email="bob@test.local")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|