import pytest from unittest.mock import MagicMock, patch import sys from imgui_bundle import imgui_node_editor as ed def test_imgui_node_editor_import(): assert ed is not None assert hasattr(ed, "begin_node") assert hasattr(ed, "end_node") def test_app_has_node_editor_attrs(): from src.gui_2 import App # Use patch to avoid initializing the entire App with patch('src.app_controller.AppController'), \ patch('src.gui_2.immapp.RunnerParams'), \ patch('imgui_bundle.imgui_node_editor.create_editor'): app = App.__new__(App) # Manually set what we expect from __init__ app.node_editor_config = ed.Config() app.node_editor_ctx = ed.create_editor(app.node_editor_config) app.ui_selected_ticket_id = None assert hasattr(app, 'node_editor_config') assert hasattr(app, 'node_editor_ctx') assert hasattr(app, 'ui_selected_ticket_id') def test_node_id_stability(): """Verify that node/pin IDs generated via hash are stable for the same input.""" tid = "T-001" int_id = abs(hash(tid)) in_pin_id = abs(hash(tid + "_in")) out_pin_id = abs(hash(tid + "_out")) # Re-generate and compare assert int_id == abs(hash(tid)) assert in_pin_id == abs(hash(tid + "_in")) assert out_pin_id == abs(hash(tid + "_out")) # Verify uniqueness assert int_id != in_pin_id assert int_id != out_pin_id assert in_pin_id != out_pin_id def test_link_id_stability(): """Verify that link IDs are stable.""" source_tid = "T-001" target_tid = "T-002" link_id = abs(hash(source_tid + "_" + target_tid)) assert link_id == abs(hash(source_tid + "_" + target_tid)) assert link_id != abs(hash(target_tid + "_" + source_tid))