| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- """§4 小区管理"""
- import pytest
- pytestmark = pytest.mark.integration
- def test_community_and_binding(api, uid):
- community = api.assert_success(
- api.post(
- "/communities",
- json={
- "name": f"测试小区{uid}",
- "totalHouseholds": 500,
- "avgPrice": 30000,
- "deliveryYear": 2020,
- "storeId": 1,
- "address": "测试路1号",
- },
- ),
- status=201,
- )
- cid = community["id"]
- room_id = f"room-{uid}"
- binding = api.assert_success(
- api.post(
- "/community-room-bindings",
- json={"communityId": cid, "roomId": room_id, "storeId": 1},
- ),
- status=201,
- )
- bind_id = binding["id"]
- by_room = api.assert_success(api.get(f"/community-room-bindings/by-room/{room_id}"))
- assert by_room["communityId"] == cid
- bindings = api.assert_success(api.get("/community-room-bindings"))
- assert any(b["id"] == bind_id for b in bindings)
- updated = api.assert_success(
- api.put(f"/communities/{cid}", json={"remark": "pytest"})
- )
- assert updated["remark"] == "pytest"
- api.assert_success(api.delete(f"/community-room-bindings/{bind_id}"))
- api.assert_success(api.delete(f"/communities/{cid}"))
|