"""§3 人员管理""" import pytest pytestmark = pytest.mark.integration def test_staff_crud(api, uid): phone = f"138{uid[:8]}" created = api.assert_success( api.post( "/staff", json={ "name": f"测试员工{uid}", "role": "designer", "storeId": 1, "phone": phone, }, ), status=201, ) staff_id = created["id"] assert created["name"] == f"测试员工{uid}" listed = api.assert_success(api.get("/staff", params={"role": "designer"})) assert any(s["id"] == staff_id for s in listed) detail = api.assert_success(api.get(f"/staff/{staff_id}")) assert detail["phone"] == phone updated = api.assert_success( api.put(f"/staff/{staff_id}", json={"guid": f"guid-{uid}", "status": 1}) ) assert updated["guid"] == f"guid-{uid}" guids_data = api.assert_success(api.get("/staff/active-guids")) assert "guids" in guids_data assert isinstance(guids_data["guids"], list) api.assert_success(api.delete(f"/staff/{staff_id}")) def test_staff_validation(api): api.assert_error( api.post("/staff", json={"name": "x"}), 400, "VALIDATION_ERROR", )