feat(收尾): 附录A#10联系人CRUD补齐(serializer可写FK+前端dialog+test_contact_crud) / D2真机重跑全绿 / 后端512+PG4
This commit is contained in:
@@ -89,3 +89,30 @@ def test_anon_cannot_access(anon, tenant):
|
||||
anon.credentials(HTTP_X_TENANT_ID=tenant.code)
|
||||
resp = anon.get("/api/v1/partner/customers/")
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_contact_crud(auth_client, tenant):
|
||||
# 新建(无挂靠)
|
||||
resp = auth_client.post(
|
||||
"/api/v1/partner/contacts/",
|
||||
{"name": "张三", "phone": "13800138000", "title": "采购"},
|
||||
format="json",
|
||||
)
|
||||
assert resp.status_code == 201, resp.content
|
||||
cid = resp.json()["id"]
|
||||
# 编辑
|
||||
resp = auth_client.patch(
|
||||
f"/api/v1/partner/contacts/{cid}/",
|
||||
{"title": "采购经理"},
|
||||
format="json",
|
||||
)
|
||||
assert resp.status_code == 200, resp.content
|
||||
assert resp.json()["title"] == "采购经理"
|
||||
# 列表可见
|
||||
resp = auth_client.get("/api/v1/partner/contacts/")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["count"] == 1
|
||||
# 删除
|
||||
resp = auth_client.delete(f"/api/v1/partner/contacts/{cid}/")
|
||||
assert resp.status_code in (200, 202, 204), resp.content
|
||||
|
||||
Reference in New Issue
Block a user