mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
api layer v0.2.4 - /nettools/speedtest endpoint
This commit is contained in:
@@ -71,6 +71,26 @@ def test_wakeonlan_device(client, api_token, test_mac):
|
||||
data = resp.json
|
||||
assert data.get("success") is True
|
||||
assert "WOL packet sent" in data.get("message", "")
|
||||
|
||||
def test_speedtest_endpoint(client, api_token):
|
||||
# 1. Call the speedtest endpoint
|
||||
resp = client.get("/nettools/speedtest", headers=auth_headers(api_token))
|
||||
|
||||
# 2. Assertions
|
||||
if resp.status_code == 403:
|
||||
# Unauthorized access
|
||||
data = resp.json
|
||||
assert "error" in data
|
||||
assert data["error"] == "Forbidden"
|
||||
else:
|
||||
# Expect success
|
||||
assert resp.status_code == 200
|
||||
data = resp.json
|
||||
assert data.get("success") is True
|
||||
assert "output" in data
|
||||
assert isinstance(data["output"], list)
|
||||
# Optionally check that output lines are strings
|
||||
assert all(isinstance(line, str) for line in data["output"])
|
||||
|
||||
def test_traceroute_device(client, api_token, test_mac):
|
||||
# 1. Ensure at least one device exists
|
||||
@@ -106,4 +126,4 @@ def test_traceroute_device(client, api_token, test_mac):
|
||||
assert "output" in data
|
||||
assert isinstance(data["output"], str)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user