"""Tests for the XML parser.""" from __future__ import annotations import sys import textwrap from pathlib import Path import pytest PKG = Path(__file__).parent.parent # alteryx_runner/ if str(PKG) not in sys.path: sys.path.insert(0, str(PKG)) from engine.parser import parse_workflow def _write_yxmd(tmp_path: Path, body: str) -> Path: content = f'{body}' p = tmp_path / "test.yxmd" p.write_text(content) return p class TestParser: def test_simple_nodes(self, tmp_path): body = textwrap.dedent("""\ True """) path = _write_yxmd(tmp_path, body) graph = parse_workflow(str(path)) assert 1 in graph.nodes assert 2 in graph.nodes assert len(graph.connections) == 1 assert graph.connections[0].origin_id == 1 assert graph.connections[0].dest_id == 2 def test_wireless_connection(self, tmp_path): body = textwrap.dedent("""\ """) path = _write_yxmd(tmp_path, body) graph = parse_workflow(str(path)) assert graph.connections[0].wireless is True def test_node_position(self, tmp_path): body = textwrap.dedent("""\ """) path = _write_yxmd(tmp_path, body) graph = parse_workflow(str(path)) assert graph.nodes[5].position == (42, 99)