Harden track_presence generator option and fix test fixtures

Set the presence flag after the submessage decode, dump it in verbose
protobuf dumps, and raise at generation time when track_presence is set
on a field where it has no effect. Retire the absent-field expectation
in the integration test so the UTC phase sees the first matching state,
and align the Sydney TZ strings with the 03:00 fall-back the struct
helper uses.
This commit is contained in:
J. Nick Koston
2026-08-21 15:24:12 -05:00
parent 061f90822c
commit 5354499724
5 changed files with 28 additions and 7 deletions
+4 -4
View File
@@ -84,7 +84,7 @@ static ParsedTimezone make_new_zealand() {
return tz;
}
// Helper to build Australia/Sydney timezone (AEST-10AEDT,M10.1.0,M4.1.0)
// Helper to build Australia/Sydney timezone (AEST-10AEDT,M10.1.0,M4.1.0/3)
static ParsedTimezone make_australia_sydney() {
ParsedTimezone tz{};
tz.std_offset_seconds = -10 * 3600;
@@ -674,9 +674,9 @@ TEST(RecalcTimestampLocal, FallBackRepeatedHour) {
}
TEST(RecalcTimestampLocal, SouthernHemisphereDST) {
// Set timezone to Australia/Sydney (AEST-10AEDT,M10.1.0,M4.1.0)
// Set timezone to Australia/Sydney (AEST-10AEDT,M10.1.0,M4.1.0/3)
// DST starts first Sunday of October, ends first Sunday of April
const char *tz_str = "AEST-10AEDT,M10.1.0,M4.1.0";
const char *tz_str = "AEST-10AEDT,M10.1.0,M4.1.0/3";
setenv("TZ", tz_str, 1);
tzset();
auto tz = make_australia_sydney();
@@ -817,7 +817,7 @@ TEST(RecalcTimestampLocal, MinimalFieldsNoDST) {
TEST(RecalcTimestampLocal, YearBoundaryDST) {
// Test southern hemisphere DST across year boundary
// Australia/Sydney: DST active from October to April (spans Jan 1)
const char *tz_str = "AEST-10AEDT,M10.1.0,M4.1.0";
const char *tz_str = "AEST-10AEDT,M10.1.0,M4.1.0/3";
setenv("TZ", tz_str, 1);
tzset();
auto tz = make_australia_sydney();
@@ -55,6 +55,9 @@ async def test_api_get_time_response_timezone(
client._connection.send_messages((resp,))
await tracker.await_must_not_change(future, "tz_offset", timeout=1.0)
assert tracker.sensor_states["tz_offset"][-1] == target
# Retire the expectation so it cannot swallow the first matching state
# meant for the next phase
future.cancel()
# Present but all zero (genuine UTC): applied
future = tracker.expect("tz_offset", 0)