#!/usr/bin/env python3
"""
#exonware/xwsystem/tests/1.unit/operations_tests/runner.py

Test runner for operations module.

Company: eXonware.com
Author: Eng. Muhammad AlShehri
Email: connect@exonware.com
Version: 0.0.1.387
Generation Date: October 27, 2025

Usage:
 python tests/1.unit/operations_tests/runner.py
"""

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


def main():
 """Run operations module tests."""
 # Add src to Python path
 src_path = Path(__file__).parent.parent.parent.parent / "src"
 sys.path.insert(0, str(src_path))

 module_name = Path(__file__).parent.name.replace('_tests', '')
 print(f" Testing: {module_name}")

 # Run module tests
 exit_code = pytest.main([
 "-v",
 "--tb=short",
 "-x", # Stop on first failure
 str(Path(__file__).parent),
 "-m", "xsystem_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:** `xsystem_unit`

**Options:**
- Verbose output (`-v`)
- Short traceback (`--tb=short`)
- Stop on first failure (`-x`)

---

## Test Coverage

This module tests operations functionality covering:

1. **Merge Operations**
 - Deep merge
 - Shallow merge
 - Multiple strategies
 - Thread safety

2. **Diff Operations**
 - Structure comparison
 - Content comparison
 - Multiple modes
 - Performance

3. **Patch Operations**
 - RFC 6902 compliance
 - All operation types
 - Error handling
 - Security validation

---

## Priority Alignment

Tests validate all 5 eXonware priorities:

| Priority | Coverage |
|----------|----------|
| **#1 Security** | Input validation, safe operations, no mutation |
| **#2 Usability** | Clear API, helpful errors, convenience functions |
| **#3 Maintainability** | Clean structure, reusable operations |
| **#4 Performance** | Efficient operations, thread-safe, benchmarks |
| **#5 Extensibility** | Multiple strategies, RFC compliance, extensible |

---

## Result

{'✅ PASSED' if exit_code == 0 else '❌ FAILED'}

**Exit Code:** {exit_code}

---

*Generated by eXonware test runner - Excellence Edition*
"""

 output_file.write_text(markdown_content, encoding='utf-8')

 sys.exit(exit_code)


if __name__ == "__main__":
 main()

