testing
por contentstack
Usar para suites de pruebas unitarias/API/mock de pytest, tests/cred.py, configuración de .env e higiene en contentstack-management-python.
npx skills add https://github.com/contentstack/contentstack-management-python --skill testingTesting – Contentstack Management Python
When to use
- Adding or changing tests under
tests/. - Debugging API vs mock failures; improving
tests/cred.pyusage.
Instructions
Runner and tooling
| Suite | Path | Notes |
|---|---|---|
| Unit | tests/unit/** | Fast, isolated; primary CI target |
| API | tests/api/** | Live CMA — .env via tests/cred.py |
| Mock | tests/mock/** | Mocked HTTP / contracts |
| Goal | Command |
|---|---|
| Unit (CI-style) | pytest tests/unit/ -v or coverage run -m pytest tests/unit/ |
| API (live CMA) | pytest tests/api/ -v |
| Mock | pytest tests/mock/ -v |
| Full tree | pytest tests/ -v |
Environment (tests/cred.py)
get_credentials()loads dotenv and returns host, tokens, and resource UIDs.- Common vars:
HOST,APIKEY,AUTHTOKEN,MANAGEMENT_TOKEN,ORG_UID, plus resource UIDs as tests require. - Use a
.envat repo root for local API runs; never commit secrets.
Hygiene
- No committed secrets; use placeholders or env-only values for CI.
- Avoid leaving
pytest.skipor focused-only tests enabled in paths meant for full suite runs unless intentional.