Cache envoy auth tokens to ensure integration works if cloud is offline (#97872)
This commit is contained in:
parent
6a65a97715
commit
00e78fbf19
10 changed files with 65 additions and 34 deletions
|
@ -7,6 +7,7 @@ from pyenphase import (
|
|||
EnvoyInverter,
|
||||
EnvoySystemConsumption,
|
||||
EnvoySystemProduction,
|
||||
EnvoyTokenAuth,
|
||||
)
|
||||
import pytest
|
||||
|
||||
|
@ -43,12 +44,13 @@ def config_fixture():
|
|||
|
||||
|
||||
@pytest.fixture(name="mock_envoy")
|
||||
def mock_envoy_fixture(serial_number, mock_authenticate, mock_setup):
|
||||
def mock_envoy_fixture(serial_number, mock_authenticate, mock_setup, mock_auth):
|
||||
"""Define a mocked Envoy fixture."""
|
||||
mock_envoy = Mock(spec=Envoy)
|
||||
mock_envoy.serial_number = serial_number
|
||||
mock_envoy.authenticate = mock_authenticate
|
||||
mock_envoy.setup = mock_setup
|
||||
mock_envoy.auth = mock_auth
|
||||
mock_envoy.data = EnvoyData(
|
||||
system_consumption=EnvoySystemConsumption(
|
||||
watt_hours_last_7_days=1234,
|
||||
|
@ -99,6 +101,12 @@ def mock_authenticate():
|
|||
return AsyncMock()
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_auth")
|
||||
def mock_auth(serial_number):
|
||||
"""Define a mocked EnvoyAuth fixture."""
|
||||
return EnvoyTokenAuth("127.0.0.1", token="abc", envoy_serial=serial_number)
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_setup")
|
||||
def mock_setup():
|
||||
"""Define a mocked Envoy.setup fixture."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue