Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for router status, load, and reboot #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion tests/test_glinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncio
import pytest
from gli4py.enums import TailscaleConnection
from gli4py.error_handling import NonZeroResponse
from gli4py.glinet import GLinet

router = GLinet(base_url="http://192.168.0.1/rpc")
Expand Down Expand Up @@ -69,19 +70,48 @@ async def test_router_info() -> None:
assert('mac' in response)
print(response)

@pytest.mark.asyncio
async def test_router_get_status() -> None:
response = await router.router_get_status()
assert('service' in response)
assert('network' in response)
assert('system' in response)
assert('wifi' in response)
system = response.get("system")
assert('uptime' in system)
assert('load_average' in system)
print(response)

@pytest.mark.asyncio
async def test_router_get_load() -> None:
response = await router.router_get_load()
assert('load_average' in response)
assert('memory_free' in response)
assert('memory_total' in response)
print(response)

@pytest.mark.asyncio
async def test_router_mac() -> None:
response = await router.router_mac()
assert('factory_mac' in response)
print(response)

@pytest.mark.asyncio
async def test_router_reboot() -> None:
response = await router.router_reboot()
print(response)
await asyncio.sleep(5)
while not await router.router_reachable():
await asyncio.sleep(1)
with pytest.raises(NonZeroResponse):
await router.router_info()

@pytest.mark.asyncio
async def test_connected_clients() -> None:
clients = await router.connected_clients()
print(len(clients))
assert(len(clients) > 0)


@pytest.mark.asyncio
async def test_wireguard_client_list() -> None:
response = await router.wireguard_client_list()
Expand Down