|
| 1 | +# Tests for capiscio-python CLI |
| 2 | + |
| 3 | +This directory contains unit and E2E tests for the `capiscio` CLI wrapper. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +tests/ |
| 9 | +├── unit/ # Unit tests with mocks (no server required) |
| 10 | +│ ├── test_cli.py |
| 11 | +│ └── test_manager.py |
| 12 | +└── e2e/ # E2E tests (offline mode, no server required) |
| 13 | + ├── conftest.py # Pytest fixtures and configuration |
| 14 | + ├── fixtures/ # Test data files |
| 15 | + │ ├── valid-agent-card.json |
| 16 | + │ ├── invalid-agent-card.json |
| 17 | + │ └── malformed.txt |
| 18 | + ├── test_validate_e2e.py # Validation command tests |
| 19 | + └── test_badge_e2e.py # Badge issuance/verification tests |
| 20 | +``` |
| 21 | + |
| 22 | +## Running Tests |
| 23 | + |
| 24 | +### Run All Tests |
| 25 | + |
| 26 | +```bash |
| 27 | +pytest # All tests |
| 28 | +pytest tests/unit/ # Unit tests only |
| 29 | +pytest tests/e2e/ # E2E tests only |
| 30 | +``` |
| 31 | + |
| 32 | +### Run Specific Test File |
| 33 | + |
| 34 | +```bash |
| 35 | +pytest tests/e2scio --cov-report=html |
| 36 | +``` |
| 37 | + |
| 38 | +## E2E Test Design |
| 39 | + |
| 40 | +The E2E tests are designed to run **offline** without requiring a server: |
| 41 | + |
| 42 | +- **Validate tests**: Use `--schema-only` flag for local schema validation |
| 43 | +- **Badge tests**: Use `--self-sign` for issuance and `--accept-self-signed --offline` for verification |
| 44 | + |
| 45 | +This approach allows E2E tests to run in CI without complex server infrastructure. |
| 46 | + |
| 47 | +## Test Coverage |
| 48 | + |
| 49 | +### Validate Command (`test_validate_e2e.py`) |
| 50 | + |
| 51 | +- ✅ Valid local agent card file (schema-only mode) |
| 52 | +- ✅ Invalid local agent card file |
| 53 | +- ✅ Malformed JSON file |
| 54 | +- ✅ Nonexistent file |
| 55 | +- ✅ JSON output format |
| 56 | +- ✅ Help command |
| 57 | + |
| 58 | +### ├── test_validate_e2e.sue self-signed badge |
| 59 | +- ✅ Issue badge with custom expiration |
| 60 | +- ✅ Issue badge with audience restriction |
| 61 | +- ✅ Verify self-signed badge (offline) |
| 62 | +- ✅ Verify invalid token (error handling) |
| 63 | +- ✅ Help commands (badge, issue, verify) |
| 64 | + |
| 65 | +## CI/CD Integration |
| 66 | + |
| 67 | +The E2E tests run in GitHub Actions without server dependencies: |
| 68 | + |
| 69 | +```yaml |
| 70 | +# See .github/workflows/e2e.yml |
| 71 | +- name: Run E2E tests |
| 72 | + run: pytest tests/e2e/ |
| 73 | +``` |
| 74 | +
|
| 75 | +## Notes |
| 76 | +
|
| 77 | +- **Offline Mode**: All E2E tests run offline without server dependencies |
| 78 | +- **Download Messages**: On first run, the CLI may download the capiscio-core binary; tests handle this gracefully |
| 79 | +
|
| 80 | +## Troubleshooting |
| 81 | +
|
| 82 | +### Build/Install Issues |
| 83 | +
|
| 84 | +Ensure the project is installed: |
| 85 | +
|
| 86 | +```bash |
| 87 | +pip install -e . |
| 88 | +pytest tests/e2e/ |
| 89 | +``` |
| 90 | + |
| 91 | +### Path Issues |
| 92 | + |
| 93 | +Ensure you're running pytest from the project root: |
| 94 | + |
| 95 | +```bash |
| 96 | +cd /path/to/capiscio-python |
| 97 | +pytest tests/e2e/ |
| 98 | +``` |
0 commit comments