|
1 | | -# test_cli_run.py |
2 | | -from agent_os.policies.cli import success, error, warn, policy_violation, passed_check |
| 1 | +from agent_os.policies.cli import success,error,warn,policy_violation,passed_check |
3 | 2 |
|
4 | | -def main(): |
5 | | - print("=== Testing CLI functions with colored output ===\n") |
6 | | - |
7 | | - print("1️⃣ success():") |
| 3 | +def test_success(capsys): |
8 | 4 | success("This is a success message") |
| 5 | + captured = capsys.readouterr() |
| 6 | + assert "success message" in captured.out.lower() |
| 7 | + |
9 | 8 |
|
10 | | - print("\n2️⃣ error():") |
| 9 | +def test_error(capsys): |
11 | 10 | error("This is an error message") |
| 11 | + captured = capsys.readouterr() |
| 12 | + assert "error message" in captured.err.lower() |
12 | 13 |
|
13 | | - print("\n3️⃣ warn():") |
| 14 | + |
| 15 | +def test_warn(capsys): |
14 | 16 | warn("This is a warning message") |
| 17 | + captured = capsys.readouterr() |
| 18 | + assert "warning message" in captured.out.lower() |
15 | 19 |
|
16 | | - print("\n4️⃣ policy_violation():") |
17 | | - policy_violation("Policy violation detected!") |
18 | 20 |
|
19 | | - print("\n5️⃣ passed_check():") |
20 | | - passed_check("Test passed successfully!") |
| 21 | +def test_policy_violation(capsys): |
| 22 | + policy_violation("Policy violation detected!") |
| 23 | + captured = capsys.readouterr() |
| 24 | + assert "policy violation" in captured.out.lower() |
21 | 25 |
|
22 | | - print("\n=== Done testing CLI functions ===") |
23 | 26 |
|
24 | | -if __name__ == "__main__": |
25 | | - main() |
| 27 | +def test_passed_check(capsys): |
| 28 | + passed_check("Test passed successfully!") |
| 29 | + captured = capsys.readouterr() |
| 30 | + assert "test passed" in captured.out.lower() |
0 commit comments