Skip to content

Commit 3116663

Browse files
authored
Add tests for log creation and listing
1 parent eceb6ba commit 3116663

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

backend/tests/test_logs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from fastapi.testclient import TestClient
2+
from backend.main import app
3+
4+
client = TestClient(app)
5+
6+
def test_create_log():
7+
payload = {
8+
"timestamp": "2025-01-01T00:00:00Z",
9+
"source_ip": "10.0.0.1",
10+
"destination_ip": "10.0.0.2",
11+
"bytes_sent": 1234,
12+
"bytes_received": 5678,
13+
"protocol": "TCP",
14+
"status": "OK"
15+
}
16+
resp = client.post("/logs/", json=payload)
17+
assert resp.status_code in (200, 201)
18+
19+
def test_list_logs():
20+
resp = client.get("/logs/")
21+
assert resp.status_code == 200
22+
data = resp.json()
23+
assert isinstance(data, list) or isinstance(data, dict)

0 commit comments

Comments
 (0)