43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
import pytest
|
|
from httpx import AsyncClient, ASGITransport
|
|
from app.main import app
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_workstation_status_existente():
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
|
response = await client.get("/api/v1/control-posts/workstation/CFT-DESK/status")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["workstation_name"].upper() == "CFT-DESK"
|
|
assert data["is_control_post"] is True
|
|
assert data["workstation_id"] == 100001
|
|
assert len(data["modules"]) > 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_workstation_status_no_registrada():
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
|
response = await client.get("/api/v1/control-posts/workstation/TABLET_DESCONOCIDA_999/status")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["is_control_post"] is False
|
|
assert len(data["modules"]) == 0
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_listar_workstations():
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
|
response = await client.get("/api/v1/control-posts/workstations")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert isinstance(data, list)
|
|
nombres = [item["nombre"].upper() for item in data]
|
|
assert "CFT-DESK" in nombres
|