|
| 1 | +"""Smoke tests for sync + async clients.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from eleata_peppol import AsyncClient, Client, EleataError |
| 6 | + |
| 7 | + |
| 8 | +def test_client_requires_api_key(): |
| 9 | + with pytest.raises(EleataError): |
| 10 | + Client(api_key="") |
| 11 | + |
| 12 | + |
| 13 | +def test_client_rejects_oversized_payload(): |
| 14 | + client = Client(api_key="evk_test", max_payload=100) |
| 15 | + with pytest.raises(EleataError, match="exceeds"): |
| 16 | + client.validate(format="peppol-bis-3", xml=b"x" * 200) |
| 17 | + |
| 18 | + |
| 19 | +def test_async_client_requires_api_key(): |
| 20 | + with pytest.raises(EleataError): |
| 21 | + AsyncClient(api_key="") |
| 22 | + |
| 23 | + |
| 24 | +@pytest.mark.asyncio |
| 25 | +async def test_async_client_rejects_oversized_payload(): |
| 26 | + async with AsyncClient(api_key="evk_test", max_payload=100) as client: |
| 27 | + with pytest.raises(EleataError, match="exceeds"): |
| 28 | + await client.validate(format="peppol-bis-3", xml=b"x" * 200) |
| 29 | + |
| 30 | + |
| 31 | +def test_client_accepts_str_xml(): |
| 32 | + """String input should be coerced to bytes (encoded utf-8).""" |
| 33 | + client = Client(api_key="evk_test", max_payload=1000) |
| 34 | + # Will fail at network level but not at payload check |
| 35 | + with pytest.raises(EleataError) as exc: |
| 36 | + client.validate(format="ubl", xml="<x/>") |
| 37 | + assert "exceeds" not in str(exc.value) |
0 commit comments