| """目标储存条件解析测试(命名条件 / ICH Zone / 冷链条件 + 标准值补齐标注)。 |
| |
| 覆盖修复点:用户以「加速条件 / 中间条件 / 长期条件 / Zone Ⅳb / 冷藏 / 冷冻」等 |
| **名称**指定目标条件而未写温湿度数字时,系统应按 ICH 标准值补齐温湿度,并标注 |
| 其为标准值(不静默注入);显式温湿度数字应优先采用。 |
| """ |
|
|
| from skills.stability.skill import ( |
| _condition_type_from_goal, |
| _target_condition_from_goal, |
| _zone_type_from_goal, |
| ) |
|
|
|
|
| def test_accelerated_named_condition_fills_standard_temp_rh(): |
| cond = _target_condition_from_goal("预测加速试验条件下1个月时的降解产物水平") |
| assert cond is not None |
| assert cond["condition_type"] == "accelerated" |
| assert cond["temp_c"] == 40.0 |
| assert cond["rh"] == 75.0 |
| assert cond["temp_is_standard"] is True |
| assert cond["rh_is_standard"] is True |
|
|
|
|
| def test_intermediate_named_condition(): |
| cond = _target_condition_from_goal("中间条件下的稳定性预测") |
| assert cond["condition_type"] == "intermediate" |
| assert cond["temp_c"] == 30.0 |
| assert cond["rh"] == 65.0 |
|
|
|
|
| def test_longterm_defaults_zone_ii(): |
| cond = _target_condition_from_goal("长期试验条件下预测36个月货架期") |
| assert cond["condition_type"] == "longterm" |
| assert cond["temp_c"] == 25.0 |
| assert cond["rh"] == 60.0 |
|
|
|
|
| def test_explicit_numbers_take_precedence_over_standard(): |
| cond = _target_condition_from_goal("预测 25℃,60%RH 条件下 48 个月") |
| assert cond["temp_c"] == 25.0 |
| assert cond["rh"] == 60.0 |
| |
| assert cond["temp_is_standard"] is False |
| assert cond["rh_is_standard"] is False |
|
|
|
|
| def test_zone_ivb_mapping(): |
| assert _zone_type_from_goal("Zone Ⅳb 长期条件") == "zone_ivb" |
| cond = _target_condition_from_goal("Zone Ⅳb 长期条件预测") |
| assert cond["temp_c"] == 30.0 |
| assert cond["rh"] == 75.0 |
|
|
|
|
| def test_zone_arabic_numerals(): |
| assert _zone_type_from_goal("zone 2 long-term") == "zone_ii" |
| assert _zone_type_from_goal("Zone 4a") == "zone_iva" |
| assert _zone_type_from_goal("zone 3") == "zone_iii" |
| assert _zone_type_from_goal("zone 1") == "zone_i" |
|
|
|
|
| def test_refrigerated_condition_no_rh(): |
| cond = _target_condition_from_goal("冷藏条件下(2-8℃)保存的稳定性") |
| assert cond["condition_type"] == "refrigerated" |
| assert cond["temp_c"] == 5.0 |
| |
| assert cond["rh"] is None |
|
|
|
|
| def test_frozen_condition(): |
| cond = _target_condition_from_goal("冷冻 -20℃ 保存预测") |
| assert cond["condition_type"] == "frozen" |
| assert cond["temp_c"] == -20.0 |
| assert cond["rh"] is None |
|
|
|
|
| def test_deep_frozen_condition(): |
| cond = _target_condition_from_goal("-70℃ 深冷保存") |
| assert cond["condition_type"] == "deep_frozen" |
| assert cond["temp_c"] == -70.0 |
|
|
|
|
| def test_negative_temp_classified_as_frozen(): |
| assert _condition_type_from_goal("在 -18 度保存", -18.0) == "frozen" |
|
|
|
|
| def test_no_condition_returns_none(): |
| assert _target_condition_from_goal("请梳理各批次质量属性") is None |
|
|