Files
supervisor/tests/utils/test_check_port.py
Stefan Agner 883e54f989 Make check_port an async function (#4677)
* Make check_port asyncio

This requires to change the ingress_port property to a async method.

* Avoid using wait_for

* Add missing async

* Really await

* Set dynamic ingress port on add-on installation/update

* Fix pytest issue

* Rename async_check_port back to check_port

* Raise RuntimeError in case port is not set

* Make sure port gets set on add-on restore

* Drop unnecessary async

* Simplify check_port by using asyncio.get_running_loop()
2023-12-05 15:49:35 -05:00

16 lines
436 B
Python

"""Check ports."""
from ipaddress import ip_address
from supervisor.coresys import CoreSys
from supervisor.utils import check_port
async def test_exists_open_port(coresys: CoreSys):
"""Test a exists network port."""
assert await check_port(ip_address("8.8.8.8"), 53)
async def test_not_exists_port(coresys: CoreSys):
"""Test a not exists network service."""
assert not await check_port(ip_address("192.0.2.1"), 53)