Exercise one read-only command per scope.
(api: SerialStudioAPI, suite: TestSuite, available: set[str])
| 626 | |
| 627 | |
| 628 | def test_smoke(api: SerialStudioAPI, suite: TestSuite, available: set[str]): |
| 629 | """Exercise one read-only command per scope.""" |
| 630 | print(bold(info("\n[ Smoke: read-only commands ]"))) |
| 631 | |
| 632 | for cmd, scope in SMOKE_COMMANDS: |
| 633 | if cmd not in available: |
| 634 | _record( |
| 635 | suite, |
| 636 | f"{cmd} ({scope})", |
| 637 | TestResult.SKIPPED, |
| 638 | "not registered (probably GPL build or feature off)", |
| 639 | ) |
| 640 | continue |
| 641 | |
| 642 | t0 = time.time() |
| 643 | response = api.send_command(cmd) |
| 644 | duration = (time.time() - t0) * 1000 |
| 645 | |
| 646 | if response is None: |
| 647 | _record(suite, f"{cmd} ({scope})", TestResult.FAILED, "no response") |
| 648 | continue |
| 649 | |
| 650 | if response.get("success"): |
| 651 | _record(suite, f"{cmd} ({scope})", TestResult.PASSED, duration_ms=duration) |
| 652 | else: |
| 653 | err = response.get("error", {}) |
| 654 | code = err.get("code", "?") |
| 655 | # license_required is a soft pass -- the command exists, the |
| 656 | # server just won't run it without a Pro key. |
| 657 | if code == "license_required": |
| 658 | _record( |
| 659 | suite, f"{cmd} ({scope})", TestResult.SKIPPED, "license_required" |
| 660 | ) |
| 661 | else: |
| 662 | _record( |
| 663 | suite, |
| 664 | f"{cmd} ({scope})", |
| 665 | TestResult.FAILED, |
| 666 | f"{code}: {err.get('message', '')}", |
| 667 | ) |
| 668 | |
| 669 | |
| 670 | def test_blocked_commands(api: SerialStudioAPI, suite: TestSuite, available: set[str]): |