Skip to content

test: look up alerts sensor entity id dynamically#141

Merged
finity69x2 merged 1 commit into
finity69x2:masterfrom
seevee:test/dynamic-sensor-lookup
Apr 9, 2026
Merged

test: look up alerts sensor entity id dynamically#141
finity69x2 merged 1 commit into
finity69x2:masterfrom
seevee:test/dynamic-sensor-lookup

Conversation

@seevee
Copy link
Copy Markdown
Contributor

@seevee seevee commented Apr 8, 2026

Context

The configured-name change made the hard-coded sensor.nws_alerts_alerts string literal unreliable in pytest.

EDIT: tests/test_sensor.py has asserted sensor.nws_alerts since a234bff (Aug 2024), and that slug has never matched a fresh install of this integration.

The proposed changes discover the entity via the sensor domain instead so the test survives future entity_id format changes.

Notes

  • no-op change for working test setups
  • fixes my own issues running tests against arbitrarily named entities
  • statically configured test entity id -> now a dynamic entity lookup
  • tests are now slightly more reliable for a wider range of entity ids, but still equally fragile to entity name scheme changes

The configured-name change made the hard-coded sensor.nws_alerts_alerts
literal unreliable. Discover the entity via the sensor domain instead so
the test survives future entity_id format changes.
@seevee seevee marked this pull request as ready for review April 8, 2026 18:53
@seevee

This comment was marked as outdated.

@seevee seevee closed this Apr 8, 2026
@seevee
Copy link
Copy Markdown
Contributor Author

seevee commented Apr 8, 2026

Reopening with better justification than the original description. I framed this as preemptive hardening against 7eda048, but that attribution was wrong. The configured-name change isn't actually what makes the hard-coded slug unreliable.

The real situation: tests/test_sensor.py has asserted sensor.nws_alerts since a234bff (Aug 2024), and that slug has never matched a fresh install of this integration.

So the dynamic lookup here fixes a real, pre-existing bug in the test rather than a hypothetical future one, with zero user impact and no sensor.py changes.

@seevee seevee reopened this Apr 8, 2026
@finity69x2 finity69x2 merged commit 37b64dc into finity69x2:master Apr 9, 2026
8 checks passed
@seevee seevee deleted the test/dynamic-sensor-lookup branch April 9, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants