* Add expiration timestamp to cert_expiry sensors * Clear timestamp if cert becomes invalid * Use timezone-aware timestamps * Use DataUpdateCoordinator, split timestamp to separate sensor * Use UTC, simpler add/remove handling * Review fixes * Fix incomplete mock that fails in 3.8 * Use static timestamps, improve helper method name
15 lines
437 B
Python
15 lines
437 B
Python
"""Helpers for Cert Expiry tests."""
|
|
from datetime import datetime, timedelta
|
|
|
|
from homeassistant.util import dt
|
|
|
|
|
|
def static_datetime():
|
|
"""Build a datetime object for testing in the correct timezone."""
|
|
return dt.as_utc(datetime(2020, 6, 12, 8, 0, 0))
|
|
|
|
|
|
def future_timestamp(days):
|
|
"""Create timestamp object for requested days in future."""
|
|
delta = timedelta(days=days, minutes=1)
|
|
return static_datetime() + delta
|