repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | """CLI usage error regression tests.""" |
| #2 | |
| #3 | import os |
| #4 | import subprocess |
| #5 | import sys |
| #6 | |
| #7 | |
| #8 | USAGE_COMMANDS = [ |
| #9 | (["store"], "Usage: mnemosyne store <content> [source] [importance]"), |
| #10 | (["recall"], "Usage: mnemosyne recall <query> [top_k]"), |
| #11 | (["update", "missing-id"], "Usage: mnemosyne update <memory_id> <new_content> [importance]"), |
| #12 | (["delete"], "Usage: mnemosyne delete <memory_id>"), |
| #13 | (["import"], "Usage: mnemosyne import <file.json>"), |
| #14 | (["import-hindsight"], "Usage: mnemosyne import-hindsight <file.json|base_url> [bank]"), |
| #15 | (["bank"], "Usage: mnemosyne bank <list|create|delete> [name]"), |
| #16 | ] |
| #17 | |
| #18 | |
| #19 | def run_cli(args, tmp_path): |
| #20 | env = os.environ.copy() |
| #21 | env["HOME"] = str(tmp_path / "home") |
| #22 | env["MNEMOSYNE_DATA_DIR"] = str(tmp_path / "mnemosyne-data") |
| #23 | return subprocess.run( |
| #24 | [sys.executable, "-m", "mnemosyne.cli", *args], |
| #25 | text=True, |
| #26 | capture_output=True, |
| #27 | env=env, |
| #28 | check=False, |
| #29 | ) |
| #30 | |
| #31 | |
| #32 | def test_missing_required_args_report_usage_error_without_traceback(tmp_path): |
| #33 | for args, expected_usage in USAGE_COMMANDS: |
| #34 | result = run_cli(args, tmp_path) |
| #35 | |
| #36 | assert result.returncode != 0, args |
| #37 | assert result.stdout == "" |
| #38 | assert expected_usage in result.stderr |
| #39 | assert "Traceback" not in result.stderr |
| #40 | |
| #41 | |
| #42 | def test_unknown_command_reports_error_without_traceback(tmp_path): |
| #43 | result = run_cli(["definitely-not-a-command"], tmp_path) |
| #44 | |
| #45 | assert result.returncode != 0 |
| #46 | assert result.stdout == "" |
| #47 | assert "Unknown command: definitely-not-a-command" in result.stderr |
| #48 | assert "Run 'mnemosyne --help' for usage." in result.stderr |
| #49 | assert "Traceback" not in result.stderr |
| #50 | |
| #51 | |
| #52 | def test_help_exits_successfully(tmp_path): |
| #53 | result = run_cli(["--help"], tmp_path) |
| #54 | |
| #55 | assert result.returncode == 0 |
| #56 | assert "Usage: mnemosyne <command> [args]" in result.stdout |
| #57 | assert "Traceback" not in result.stderr |
| #58 |