test suite
This commit is contained in:
93
tests/test_navigation.py
Normal file
93
tests/test_navigation.py
Normal file
@@ -0,0 +1,93 @@
|
||||
"""Tests for navigation tools (windows, items, scene graph tree)."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestNavigation:
|
||||
"""Verify listQuickWindows, selectQuickWindow, listQuickItems, listScenegraphNodes."""
|
||||
|
||||
def test_tools_listed(self, bridge):
|
||||
tools = bridge.list_tools()
|
||||
names = [t["name"] for t in tools]
|
||||
for expected in ["listQuickWindows", "selectQuickWindow",
|
||||
"listQuickItems", "listScenegraphNodes"]:
|
||||
assert expected in names
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_list_windows(self, connected_bridge):
|
||||
windows = connected_bridge.call_tool("listQuickWindows")
|
||||
assert isinstance(windows, list)
|
||||
assert len(windows) >= 1
|
||||
for w in windows:
|
||||
assert "address" in w
|
||||
assert "type" in w
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_select_window(self, connected_bridge):
|
||||
result = connected_bridge.call_tool("selectQuickWindow", {"index": 0})
|
||||
assert isinstance(result, dict)
|
||||
assert result.get("status") == "selected"
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_list_items(self, connected_bridge):
|
||||
# Select window first so item model populates
|
||||
connected_bridge.call_tool("selectQuickWindow", {"index": 0})
|
||||
import time
|
||||
time.sleep(1)
|
||||
items = connected_bridge.call_tool("listQuickItems")
|
||||
assert isinstance(items, list)
|
||||
# May be empty if model hasn't populated yet; that's OK
|
||||
if items:
|
||||
assert isinstance(items[0], dict)
|
||||
assert "type" in items[0]
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_list_items_with_window_count(self, connected_bridge):
|
||||
"""Collect all items and verify at least some are found."""
|
||||
connected_bridge.call_tool("selectQuickWindow", {"index": 0})
|
||||
import time
|
||||
time.sleep(1)
|
||||
items = connected_bridge.call_tool("listQuickItems")
|
||||
|
||||
def count_all(items_list):
|
||||
count = 0
|
||||
for item in items_list:
|
||||
count += 1
|
||||
count += count_all(item.get("children", []))
|
||||
return count
|
||||
|
||||
if items:
|
||||
total = count_all(items)
|
||||
assert total > 0
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_list_scenegraph_nodes(self, connected_bridge):
|
||||
connected_bridge.call_tool("selectQuickWindow", {"index": 0})
|
||||
import time
|
||||
time.sleep(1)
|
||||
|
||||
nodes = connected_bridge.call_tool("listScenegraphNodes")
|
||||
assert isinstance(nodes, list)
|
||||
if nodes:
|
||||
assert isinstance(nodes[0], dict)
|
||||
# Root should be "Root Node"
|
||||
assert nodes[0].get("type") == "Root Node"
|
||||
|
||||
@pytest.mark.probe
|
||||
def test_scenegraph_has_geometry_nodes(self, connected_bridge):
|
||||
connected_bridge.call_tool("selectQuickWindow", {"index": 0})
|
||||
import time
|
||||
time.sleep(1)
|
||||
nodes = connected_bridge.call_tool("listScenegraphNodes")
|
||||
|
||||
def find_geometry(items_list):
|
||||
for item in items_list:
|
||||
if item.get("type") == "Geometry Node":
|
||||
return item
|
||||
found = find_geometry(item.get("children", []))
|
||||
if found:
|
||||
return found
|
||||
return None
|
||||
|
||||
geo = find_geometry(nodes)
|
||||
assert geo is not None, "No Geometry Node found in SG tree"
|
||||
Reference in New Issue
Block a user