Add additional zeroconf discovery coverage and logging to enphase_envoy (#114405)

* add debug info to zeroconf for enphase_envoy

* Implement review feedback, lost space

Co-authored-by: Charles Garwood <cgarwood@newdealmultimedia.com>

* review feedback textual changes.

* implement review feedbackw.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Add some more zeroconf tests and valid jwt

* review feedback assert abort reason and keyerror for serialnumber

* Review feedback config flow test ends with abort or create_entry

* Review feedback optimize resource usage

* Cover new code in test.

* Use caplog for debug COV

---------

Co-authored-by: Charles Garwood <cgarwood@newdealmultimedia.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Arie Catsman 2024-04-23 14:26:53 +02:00 committed by GitHub
parent b8918d7d17
commit 2c651e190f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 261 additions and 2 deletions

View file

@ -2,6 +2,7 @@
from unittest.mock import AsyncMock, Mock, patch
import jwt
from pyenphase import (
Envoy,
EnvoyData,
@ -368,7 +369,10 @@ def mock_authenticate():
@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)
token = jwt.encode(
payload={"name": "envoy", "exp": 1907837780}, key="secret", algorithm="HS256"
)
return EnvoyTokenAuth("127.0.0.1", token=token, envoy_serial=serial_number)
@pytest.fixture(name="mock_setup")