feat(bim): integrate portable IFC viewer, project map and prepared layers
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from k1link.web.bim_module import BimModuleSurface
|
||||
|
||||
|
||||
def test_bim_host_is_offline_capable_and_does_not_depend_on_fleet(tmp_path: Path):
|
||||
surface = BimModuleSurface(tmp_path)
|
||||
app = FastAPI()
|
||||
app.mount("/api/v1/bim", surface)
|
||||
try:
|
||||
with TestClient(
|
||||
app, base_url="http://localhost", client=("127.0.0.1", 50000)
|
||||
) as client:
|
||||
prefix = "/api/v1/bim"
|
||||
assert client.get(prefix + "/projects").json() == []
|
||||
project = client.post(
|
||||
prefix + "/projects", json={"name": "Объект", "contractor": "Тест"}
|
||||
)
|
||||
assert project.status_code == 201
|
||||
path = prefix + "/projects/" + project.json()["id"]
|
||||
assert client.get(path).json()["project"]["name"] == "Объект"
|
||||
assert client.get(prefix + "/capabilities").status_code == 503
|
||||
assert client.get(path).status_code == 200
|
||||
assert not surface.binding.route
|
||||
assert not list(tmp_path.rglob("*.ifc"))
|
||||
assert not list(tmp_path.rglob("source.part"))
|
||||
finally:
|
||||
surface.close()
|
||||
|
||||
|
||||
def test_bim_surface_rejects_cross_site_before_creating_state(tmp_path: Path):
|
||||
surface = BimModuleSurface(tmp_path / "uncreated")
|
||||
app = FastAPI()
|
||||
app.mount("/api/v1/bim", surface)
|
||||
with TestClient(
|
||||
app, base_url="http://localhost", client=("127.0.0.1", 50000)
|
||||
) as client:
|
||||
for headers in (
|
||||
{"Origin": "https://other.example"},
|
||||
{"Sec-Fetch-Site": "cross-site"},
|
||||
{"Host": "evil.example"},
|
||||
):
|
||||
assert (
|
||||
client.get("/api/v1/bim/projects", headers=headers).status_code == 403
|
||||
)
|
||||
assert not surface.data_dir.exists()
|
||||
assert surface.services is None
|
||||
Reference in New Issue
Block a user