mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 04:20:45 +08:00
Align folder permissions: roots deletable, root maps rename-only, world map locked.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1b592490a5
commit
77832b271d
4 changed files with 85 additions and 13 deletions
|
|
@ -666,6 +666,31 @@ class FabricTopologyTests(unittest.TestCase):
|
|||
child_ids = {c.id for c in root_map.children}
|
||||
self.assertEqual(child_ids, {a.id, b.id})
|
||||
|
||||
def test_root_map_rename_ok_but_not_direct_delete(self) -> None:
|
||||
from fastapi import HTTPException
|
||||
|
||||
from netx_api.topology_schemas import TopologyFolderUpdate
|
||||
|
||||
top = svc.create_folder(
|
||||
self.db, TopologyFolderCreate(name="North", kind="region")
|
||||
)
|
||||
tree = svc.get_topology_tree(self.db)
|
||||
assert tree.root is not None
|
||||
north = next(c for c in tree.root.children if c.id == top.id)
|
||||
root_map = north.children[0]
|
||||
self.assertTrue(root_map.is_system)
|
||||
renamed = svc.update_folder(
|
||||
self.db, root_map.id, TopologyFolderUpdate(name="主画布")
|
||||
)
|
||||
self.assertEqual(renamed.name, "主画布")
|
||||
with self.assertRaises(HTTPException) as ctx:
|
||||
svc.delete_folder(self.db, root_map.id)
|
||||
self.assertEqual(ctx.exception.detail, "cannot_delete_system_folder")
|
||||
# Deleting the manual「根」cascades the「根图」.
|
||||
out = svc.delete_folder(self.db, top.id)
|
||||
self.assertTrue(out.get("deleted"))
|
||||
self.assertIsNone(self.db.get(TopoFolder, root_map.id))
|
||||
|
||||
def test_classify_role_region_and_slices(self) -> None:
|
||||
from netx_api import topology_classify as clf
|
||||
from netx_api.topology_schemas import (
|
||||
|
|
|
|||
|
|
@ -450,6 +450,12 @@ class UmeHierarchyTests(unittest.TestCase):
|
|||
with self.assertRaises(HTTPException) as ctx2:
|
||||
delete_view(self.db, flat.id)
|
||||
self.assertEqual(ctx2.exception.detail, "cannot_delete_world_map_view")
|
||||
from netx_api.topology_schemas import TopologyViewUpdate
|
||||
from netx_api.topology_views_tree import update_view
|
||||
|
||||
with self.assertRaises(HTTPException) as ctx3:
|
||||
update_view(self.db, flat.id, TopologyViewUpdate(name="Nope"))
|
||||
self.assertEqual(ctx3.exception.detail, "cannot_rename_world_map_view")
|
||||
|
||||
def test_flat_slots_do_not_overlap(self):
|
||||
self._seed_tree()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue