Test/RiskModelParams
RiskDisplay Test Cases
We will test three different scenarios against the "BaseProfile" model (which is defined on the /Data subpage).
We will also use a dropdown to provide an external variable, user_age, to test placeholder resolution.
| user_age |
|---|
|
10 |
|
20 |
|
30 |
Test 1: Model Only
This tag uses model="BaseProfile" and provides no data- attributes or content. It should fetch and use all parameters and content directly from the database model.
Expected: Renders "Base risk score is 60. (Age: 40, Smoker: 0)"
Test 2: Model with Overrides
These tags use model="BaseProfile" but also provide their own data- attributes or content, which should override the ones from the database.
Test 2a: Overriding parameters only
This overrides age_default and smoker_default. It should use the content from the model but the new parameter values for the calculation.
Expected: Renders "Base risk score is 175. (Age: 50, Smoker: 1)" (Calculated from: (50*1.5) + (1*100) = 75 + 100 = 175)
Test 2b: Overriding parameters AND content
This overrides age_default and provides new tag content. It should use the new content and the merged parameters (its own age_default, and smoker_default etc. from the model).
Expected: Renders "Your selected age is [Age from dropdown]. The calculated risk is [Calculated total]."
Test 3: Inline Model (No "model" attribute)
This tag provides no model attribute. It must use only the data- attributes and content defined directly in the tag. It should not fetch anything from the database.