Generic test function that executes a CLI test case in TUI
(test_case: CLITestCase)
| 234 | |
| 235 | @pytest.mark.asyncio |
| 236 | async def test_cli_mapping(test_case: CLITestCase): |
| 237 | """Generic test function that executes a CLI test case in TUI""" |
| 238 | wrapper = XtopTUIWrapper( |
| 239 | datadir=XCAPTURE_DATADIR, |
| 240 | low_time=datetime.fromisoformat("2025-08-03T03:40:00"), |
| 241 | high_time=datetime.fromisoformat("2025-08-03T04:07:00") |
| 242 | ) |
| 243 | app = wrapper.create_app() |
| 244 | |
| 245 | async with app.run_test(size=(140, 50)) as pilot: |
| 246 | # Wait for initial load |
| 247 | await pilot.pause() |
| 248 | await wait_for_table_load(pilot) |
| 249 | |
| 250 | # Create mapper |
| 251 | mapper = TUITestMapper(pilot) |
| 252 | |
| 253 | # Execute test case |
| 254 | await test_case.execute_in_tui(pilot, mapper) |
| 255 | |
| 256 | # Wait for results |
| 257 | await pilot.pause() |
| 258 | await wait_for_table_load(pilot) |
| 259 | |
| 260 | # Validate |
| 261 | success = test_case.validate_result(app) |
| 262 | |
| 263 | if success: |
| 264 | print(f"✓ {test_case.name} passed") |
| 265 | else: |
| 266 | # Get actual columns for debugging |
| 267 | cols, _ = get_table_data(app) |
| 268 | print(f"✗ {test_case.name} failed - columns: {cols}") |
| 269 | raise AssertionError(f"Test {test_case.name} validation failed") |
| 270 | |
| 271 | |
| 272 | # Generate individual test functions for pytest |
no test coverage detected