v0.9.4-fix
This commit is contained in:
1 parent
3c490b3064
commit
150cf6cb7f
13 files changed
+285
-62
No files matched your search
+84
-2
@@ -634,6 +634,81 @@ mod tests {
|
||||
assert_eq!(target, 22.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn automatic_thermostat_without_active_intent_stays_idle() {
|
||||
let zone = test_zone("device");
|
||||
assert!(!zone_has_thermostat_intent_source(&zone, None, Utc::now()));
|
||||
assert!(!zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_thermostat_sources_activate_control_without_schedule() {
|
||||
let mut zone = test_zone("device");
|
||||
|
||||
zone.manual_setpoint = Some(22.0);
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
|
||||
zone.manual_setpoint = None;
|
||||
zone.manual_preset = Some("sleep".into());
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
|
||||
zone.manual_preset = None;
|
||||
zone.local_thermostat_power = Some(true);
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
|
||||
zone.local_thermostat_power = None;
|
||||
zone.control_source = "group:upstairs".into();
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
|
||||
zone.control_source = "automation.device".into();
|
||||
refresh_control_ownership(&mut zone, true);
|
||||
assert_eq!(zone.control_owner, "automation");
|
||||
assert_eq!(zone.control_source, "automation.device");
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_off_blocks_even_an_active_schedule_until_resume() {
|
||||
let mut zone = test_zone("device");
|
||||
let schedule = test_schedule("active", vec![1,2,3,4,5,6,7], "00:00", "00:00");
|
||||
zone.local_thermostat_power = Some(false);
|
||||
assert!(zone_has_thermostat_intent_source(&zone, Some(&schedule), Utc::now()));
|
||||
assert!(!zone_has_active_thermostat_intent(&zone, Some(&schedule), Utc::now()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_target_refresh_has_no_implicit_comfort_activation() {
|
||||
let mut zone = test_zone("device");
|
||||
zone.inherit_house_mode = false;
|
||||
zone.mode = "cool".into();
|
||||
zone.effective_setpoint = Some(23.0);
|
||||
|
||||
refresh_zone_runtime_target(&mut zone, &[], "cool");
|
||||
|
||||
assert_eq!(zone.effective_mode, "off");
|
||||
assert_eq!(zone.effective_setpoint, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resuming_local_off_without_schedule_stays_off() {
|
||||
let mut zone = test_zone("device");
|
||||
zone.inherit_house_mode = false;
|
||||
zone.mode = "cool".into();
|
||||
zone.demand = true;
|
||||
set_local_thermostat_power(&mut zone, false, Utc::now());
|
||||
|
||||
assert!(reset_local_thermostat_override(&mut zone));
|
||||
refresh_control_ownership(&mut zone, true);
|
||||
refresh_zone_runtime_target(&mut zone, &[], "cool");
|
||||
|
||||
assert!(zone.local_thermostat_power.is_none());
|
||||
assert_eq!(zone.control_source, "automation");
|
||||
assert_eq!(zone.effective_mode, "off");
|
||||
assert_eq!(zone.effective_setpoint, None);
|
||||
assert!(!zone.demand);
|
||||
assert!(!zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_target_refresh_applies_manual_profile_immediately() {
|
||||
let mut zone = test_zone("device");
|
||||
@@ -800,14 +875,21 @@ mod tests {
|
||||
assert!(set_house_bulk_thermostat_power(&mut zone, true));
|
||||
assert!(zone.local_thermostat_power.is_none());
|
||||
assert!(zone.local_thermostat_resume_at.is_none());
|
||||
assert_eq!(zone.control_source, "house_power");
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whole_house_on_does_not_create_a_local_on_override() {
|
||||
fn whole_house_on_creates_automatic_intent_without_local_ownership() {
|
||||
let mut zone = test_zone("device");
|
||||
zone.local_thermostat_power = None;
|
||||
assert!(!set_house_bulk_thermostat_power(&mut zone, true));
|
||||
assert!(set_house_bulk_thermostat_power(&mut zone, true));
|
||||
assert!(zone.local_thermostat_power.is_none());
|
||||
assert_eq!(zone.control_source, "house_power");
|
||||
refresh_control_ownership(&mut zone, true);
|
||||
assert_eq!(zone.control_owner, "automation");
|
||||
assert_eq!(zone.control_source, "house_power");
|
||||
assert!(zone_has_active_thermostat_intent(&zone, None, Utc::now()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user