Add testing for setting port from env var and fix pylint

This commit is contained in:
zhudhjen 2024-08-07 12:33:44 -07:00
parent 59b410980e
commit c2174a6408

View file

@ -35,14 +35,14 @@ class DashboardTestHelper:
return result
@pytest_asyncio.fixture()
async def dashboard() -> DashboardTestHelper:
@pytest_asyncio.fixture(name="dashboard")
async def fixture_dashboard() -> DashboardTestHelper:
sock, port = bind_unused_port()
args = Mock(
ha_addon=True,
configuration=get_fixture_path("conf"),
port=port,
)
os.environ["ESPHOME_DASHBOARD_PORT"] = str(port)
DASHBOARD.settings.parse_args(args)
app = web_server.make_app()
http_server = HTTPServer(app)
@ -52,6 +52,7 @@ async def dashboard() -> DashboardTestHelper:
assert DASHBOARD.settings.using_password is False
assert DASHBOARD.settings.on_ha_addon is True
assert DASHBOARD.settings.using_auth is False
assert DASHBOARD.settings.port is port
task = asyncio.create_task(DASHBOARD.async_run())
client = AsyncHTTPClient()
io_loop = IOLoop(make_current=False)