#!/usr/bin/env python3
"""
#exonware/xwnode/tests/1.unit/graph_tests/runner.py
Test runner for graph module unit tests.
Company: eXonware.com
Author: eXonware Backend Team
Email: connect@exonware.com
Version: 0.0.1
Generation Date: 11-Oct-2025
"""

import sys
import pytest
from pathlib import Path
from datetime import datetime


def main():
    """Run tests for graph module."""
    # Add src to Python path
    src_path = Path(__file__).parent.parent.parent.parent / "src"
    sys.path.insert(0, str(src_path))
    module_name = "graph"
    print(f"   Testing: {module_name}")
    # Run module tests
    exit_code = pytest.main([
        "-v",
        "--tb=short",
        str(Path(__file__).parent),
        "-m", "xwnode_unit"
    ])
    # Save Markdown output
    status = "PASSED" if exit_code == 0 else "FAILED"
    output_file = Path(__file__).parent / "runner_out.md"
    markdown_content = f"""# Module Test Results: {module_name}
**Module:** {module_name}  
**Layer:** 1.unit  
**Generated:** {datetime.now().strftime("%d-%b-%Y %H:%M:%S")}  
**Status:** {status}
---
## Test Execution
**Command:** `python tests/1.unit/{module_name}_tests/runner.py`
**Markers:** `xwnode_unit`
**Options:**
- Verbose output (`-v`)
- Short traceback (`--tb=short`)
---
## Result
{'✅ PASSED' if exit_code == 0 else '❌ FAILED'}
**Exit Code:** {exit_code}
---
*Generated by eXonware test runner - Production Excellence Edition*
"""
    output_file.write_text(markdown_content, encoding='utf-8')
    sys.exit(exit_code)
if __name__ == "__main__":
    main()
