Spaces:
Sleeping
Sleeping
| from app.mapping import STATE_MAP, build_advice, state_for | |
| from app.interpretation import build_interpretation | |
| def test_state_map_covers_all_valence_arousal_pairs(): | |
| for valence in ("Positive", "Neutral", "Negative"): | |
| for arousal in ("High", "Medium", "Low"): | |
| state, explanation = state_for(valence, arousal) | |
| assert state | |
| assert explanation | |
| assert (valence, arousal) in STATE_MAP | |
| def test_scene_field_no_longer_changes_advice_output(): | |
| door_advice = build_advice("Negative", "High", "door_or_outside_noise") | |
| play_advice = build_advice("Negative", "High", "play") | |
| assert door_advice == play_advice | |
| def test_interpretation_ignores_scene_context_for_specific_needs(): | |
| food_scene = build_interpretation( | |
| valence="Positive", | |
| arousal="Medium", | |
| scene="food", | |
| confidence_level="medium", | |
| features={ | |
| "rms_db": -24.0, | |
| "burstiness": 0.7, | |
| "bursts_per_10s": 3.0, | |
| "centroid": 1_500.0, | |
| "zcr": 0.06, | |
| }, | |
| duration_seconds=6.0, | |
| ) | |
| unknown_scene = build_interpretation( | |
| valence="Positive", | |
| arousal="Medium", | |
| scene="unknown", | |
| confidence_level="medium", | |
| features={ | |
| "rms_db": -24.0, | |
| "burstiness": 0.7, | |
| "bursts_per_10s": 3.0, | |
| "centroid": 1_500.0, | |
| "zcr": 0.06, | |
| }, | |
| duration_seconds=6.0, | |
| ) | |
| assert food_scene["primary_intent"]["key"] == unknown_scene["primary_intent"]["key"] | |
| assert food_scene["intent_candidates"] == unknown_scene["intent_candidates"] | |
| assert food_scene["sound_profile"]["signals"] | |
| assert food_scene["care"]["next_steps"] | |