@solaqua/ghosts 0.4.34 → 0.4.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,7 @@ Open a document only when its decision matches the current task.
|
|
|
7
7
|
- A script entry point hides fetching, processing or persistence. Should those stages be visible? → [Entry-point flow](entry-point-flow.md)
|
|
8
8
|
- A name suggests the wrong state or action. What should callers predict? → [Names and effects](names-and-effects.md)
|
|
9
9
|
- Two variables or declarations represent the same fact. Store both or derive one? → [Repeated state](single-source-state.md)
|
|
10
|
-
-
|
|
10
|
+
- Understanding a test requires jumping between parameters, body and helpers. Where should its conditions be visible? → [Test scenarios](visible-test-scenarios.md)
|
|
11
11
|
- Where should a new or renamed test go? → [Test file placement](test-file-placement.md)
|
|
12
12
|
- Does this test protect a distinct boundary, or repeat wiring and incidental presentation? → [Test value](test-value.md)
|
|
13
13
|
- Should a response field or component control become public? → [Public contracts](public-contract.md)
|
|
@@ -10,14 +10,12 @@ candidate_ids: ["candidate-181c8ce22f7c8a5659cffeeb"]
|
|
|
10
10
|
|
|
11
11
|
Make the conditions and expected results clear without requiring readers to trace branches or hidden setup.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Explicit setup values
|
|
14
14
|
|
|
15
|
-
Deidentified setup fragments from asynchronous coupon-reservation tests. The host project supplies the models, async creation helper and database session.
|
|
15
|
+
Deidentified setup fragments from asynchronous coupon-reservation tests. The host project supplies the models, async creation helper and database session. Each After block is a separate scenario.
|
|
16
16
|
|
|
17
17
|
### Before
|
|
18
18
|
|
|
19
|
-
The prepared payment state depends on the meaning of `linked`.
|
|
20
|
-
|
|
21
19
|
```python
|
|
22
20
|
usage = await create_coupon_usage(
|
|
23
21
|
session,
|
|
@@ -32,8 +30,6 @@ usage = await create_coupon_usage(
|
|
|
32
30
|
|
|
33
31
|
### After
|
|
34
32
|
|
|
35
|
-
Each block belongs to a separate test scenario.
|
|
36
|
-
|
|
37
33
|
```python
|
|
38
34
|
# Given: a subscription-linked reservation not yet applied to a payment
|
|
39
35
|
usage = await create_coupon_usage(
|
|
@@ -65,3 +61,40 @@ Explicit call-site values can still leave branching inside the helper. To remove
|
|
|
65
61
|
Do not select inputs or expectations through conditionals in test setup, actions or assertions.
|
|
66
62
|
|
|
67
63
|
Keep small scenario data beside the test. Move data elsewhere when its size obstructs reading the test itself. Put test cases before supporting fixtures and helpers.
|
|
64
|
+
|
|
65
|
+
## Parameterized scenarios
|
|
66
|
+
|
|
67
|
+
Keep parameterization when it makes cases easy to compare. Group related inputs under field names, and give failure cases IDs that describe the failing condition.
|
|
68
|
+
|
|
69
|
+
The following deidentified fragments illustrate an approval test. The host project supplies the async persistence helpers, organization and document types.
|
|
70
|
+
|
|
71
|
+
### Before
|
|
72
|
+
|
|
73
|
+
Positional values need the parameter header to be understood; the setup helper also chooses email and income-earner values from the settlement type.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
pytest.param("WITHHOLDING", "SOLE_PROPRIETOR", True, True, document_types)
|
|
77
|
+
# In the test body:
|
|
78
|
+
await prepare_approval(session, organization, settlement_type, document_types)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### After
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
pytest.param(
|
|
85
|
+
{"business_type": "SOLE_PROPRIETOR", "is_domestic_resident": True,
|
|
86
|
+
"is_representative": True, "tax_invoice_email": None},
|
|
87
|
+
{"settlement_type": "WITHHOLDING", "income_earner_name": "Applicant"},
|
|
88
|
+
document_types,
|
|
89
|
+
id="withholding-sole-proprietor",
|
|
90
|
+
)
|
|
91
|
+
# The parameter names are application, settlement, document_types.
|
|
92
|
+
# In the test body:
|
|
93
|
+
organization.update(application)
|
|
94
|
+
await add_submission_documents(session, organization.id, document_types)
|
|
95
|
+
await add_settlement_profile(session, organization.id, **settlement)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The helper persists the supplied settlement values; it does not choose scenario conditions or overwrite application fields. Name failure cases such as `missing-bank` and `blank-account-holder` so test output identifies the condition.
|
|
99
|
+
|
|
100
|
+
Keep the action, response checks, and resulting state/history assertions visible in the test body. This cleanup does not require a scenario class or builder.
|