Skip to content

Commit ba059f5

Browse files
committed
build: dist + tests passing
1 parent a367225 commit ba059f5

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
testpaths = tests
3+
asyncio_mode = auto
4+
addopts = -v --tb=short
5+
pythonpath = src

tests/test_client.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)