Skip to content

Commit 7bb6003

Browse files
feat(skills): add writing-unit-tests and writing-integration-tests skills (#37)
* feat(skills): add writing-unit-tests skill for integration test authoring Covers file structure, 6 test categories (happy path, request verification, error paths, edge cases, response shape, business logic), mocking patterns, coverage expectations, and common gotchas. * feat(skills): add writing-integration-tests skill for e2e API testing * fix(skills): scope mock_context auth examples to platform OAuth vs custom auth * docs(skills): update upgrading-sdk-v2 with ActionError cost_usd and output schema cleanup - Add ActionError with cost_usd example for cost-bearing error paths - Add conversion pattern for preserving cost_usd during migration - Add step to remove 'error' property from output schemas in config.json - Add output schema cleanup to checklist Addresses feedback from Ninos.
1 parent 313077d commit 7bb6003

4 files changed

Lines changed: 880 additions & 0 deletions

File tree

skills/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Agent skills for AI coding assistants (Amp, Claude Code, etc.) that automate com
77
| Skill | Description |
88
|-------|-------------|
99
| [`upgrading-sdk-v2/`](upgrading-sdk-v2/) | Upgrades an integration from SDK 1.x to 2.0.0 |
10+
| [`writing-unit-tests/`](writing-unit-tests/) | Writes pytest unit tests for an integration using mock_context + FetchResponse |
11+
| [`writing-integration-tests/`](writing-integration-tests/) | Writes pytest e2e integration tests that call real APIs using the live_context fixture |
1012

1113
## Setup
1214

skills/upgrading-sdk-v2/SKILL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ return ActionResult(data={"result": False, "error": str(e), "items": []}, cost_u
2020

2121
# After — ActionError (returns ResultType.ACTION_ERROR, skips schema validation)
2222
return ActionError(message=str(e))
23+
24+
# After — ActionError with cost (when a billable API call was made before the error)
25+
return ActionError(message=str(e), cost_usd=0.01)
2326
```
2427

2528
`ActionError` is a dataclass, not an exception — **return it, do not raise it.**
@@ -28,6 +31,7 @@ Convert ALL of these patterns:
2831
- `return ActionResult(data={"error": ...})``return ActionError(message=...)`
2932
- `return ActionResult(data={"result": False, "error": ..., <extra keys>})``return ActionError(message=...)` (extra keys like `"items": []` are dropped — ActionError only carries a message)
3033
- Exception catch blocks: `return ActionResult(data={"error": str(e)})``return ActionError(message=str(e))`
34+
- Cost-bearing error paths: `return ActionResult(data={"error": str(e)}, cost_usd=0.01)``return ActionError(message=str(e), cost_usd=0.01)` — preserve the cost so billing is accurate
3135

3236
### SDK 2.0.0 — FetchResponse (breaking change)
3337

@@ -89,6 +93,7 @@ For every `context.fetch()` call site:
8993
2. Convert every `return ActionResult(data={"error": ...})` to `return ActionError(message=...)`
9094
3. Convert every `return ActionResult(data={"result": False, "error": ...})` to `return ActionError(message=...)`
9195
4. Convert every `except Exception as e: return ActionResult(data={"error": str(e)})` to `return ActionError(message=str(e))`
96+
5. Remove the `"error"` property (and any `"result": bool` property used only for error signalling) from each action's output schema in `config.json` — these fields are no longer returned in the action output
9297

9398
**Do NOT change:**
9499
- Error handling (`try/except`) — exceptions are raised the same way
@@ -249,6 +254,7 @@ Before considering an integration upgraded, verify:
249254
- [ ] All `context.fetch()` return values access `.data` for the body
250255
- [ ] All error paths return `ActionError(message=...)` instead of `ActionResult` with error data
251256
- [ ] `ActionError` is imported from the SDK
257+
- [ ] `"error"` and error-only `"result"` properties removed from output schemas in `config.json`
252258
- [ ] `requirements.txt` pins `autohive-integrations-sdk~=2.0.0`
253259
- [ ] `config.json` version is bumped to `2.0.0`
254260
- [ ] Unit test mocks wrap return values in `FetchResponse(...)`

0 commit comments

Comments
 (0)