Skip to content

Commit 6b7b9e9

Browse files
tests
1 parent cc40106 commit 6b7b9e9

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# test-runner/tests/test_rpi_zebra.py
2+
"""
3+
Testy integracji RPI Server z drukarkami ZEBRA
4+
"""
5+
import pytest
6+
import requests
7+
import socket
8+
9+
10+
class TestRPIZebraIntegration:
11+
"""Testy integracji RPI z drukarkami ZEBRA"""
12+
13+
@pytest.fixture
14+
def rpi_url(self):
15+
"""URL do RPI Server"""
16+
return "http://rpi-server:8081"
17+
18+
@pytest.fixture
19+
def zebra1_host(self):
20+
"""Host drukarki ZEBRA-001"""
21+
return ("zebra-printer-1", 9100)
22+
23+
@pytest.fixture
24+
def zebra2_host(self):
25+
"""Host drukarki ZEBRA-002"""
26+
return ("zebra-printer-2", 9100)
27+
28+
def test_rpi_can_reach_zebra1(self, zebra1_host):
29+
"""Test czy można połączyć się z ZEBRA Printer 1"""
30+
host, port = zebra1_host
31+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
32+
sock.settimeout(5)
33+
34+
try:
35+
result = sock.connect_ex((host, port))
36+
assert result == 0, f"Nie można połączyć się z {host}:{port}"
37+
finally:
38+
sock.close()
39+
40+
def test_rpi_can_reach_zebra2(self, zebra2_host):
41+
"""Test czy można połączyć się z ZEBRA Printer 2"""
42+
host, port = zebra2_host
43+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
44+
sock.settimeout(5)
45+
46+
try:
47+
result = sock.connect_ex((host, port))
48+
assert result == 0, f"Nie można połączyć się z {host}:{port}"
49+
finally:
50+
sock.close()
51+
52+
def test_rpi_health_endpoint(self, rpi_url):
53+
"""Test endpointu health RPI Server"""
54+
response = requests.get(f"{rpi_url}/health", timeout=10)
55+
assert response.status_code == 200
56+
57+
data = response.json()
58+
assert 'status' in data
59+
assert data['status'] == 'ok'
60+
61+
def test_zebra1_status_api(self):
62+
"""Test API statusu ZEBRA Printer 1"""
63+
response = requests.get("http://zebra-printer-1:8080/api/status", timeout=10)
64+
assert response.status_code == 200
65+
66+
data = response.json()
67+
assert 'name' in data
68+
assert 'status' in data
69+
70+
def test_zebra2_status_api(self):
71+
"""Test API statusu ZEBRA Printer 2"""
72+
response = requests.get("http://zebra-printer-2:8080/api/status", timeout=10)
73+
assert response.status_code == 200
74+
75+
data = response.json()
76+
assert 'name' in data
77+
assert 'status' in data

0 commit comments

Comments
 (0)