Using pydantic instead of dataclasses

This commit is contained in:
Jonas Linter
2025-10-07 16:06:53 +02:00
parent e5a295faba
commit e605af1231
5 changed files with 319 additions and 35 deletions

View File

@@ -17,15 +17,11 @@ def extract_relevant_sections(xml_string):
@pytest.mark.asyncio
async def test_ping_action_response_matches_expected():
with open("test/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
server = AlpineBitsServer()
with open(
"test/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8"
) as f:
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
request_xml = f.read()
with open(
"test/test_data/Handshake-OTA_PingRS.xml", encoding="utf-8"
) as f:
with open("tests/test_data/Handshake-OTA_PingRS.xml", encoding="utf-8") as f:
expected_xml = f.read()
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
response = await server.handle_request(
@@ -56,7 +52,7 @@ async def test_ping_action_response_matches_expected():
@pytest.mark.asyncio
async def test_ping_action_response_success():
server = AlpineBitsServer()
with open("test/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
request_xml = f.read()
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
response = await server.handle_request(
@@ -74,7 +70,7 @@ async def test_ping_action_response_success():
@pytest.mark.asyncio
async def test_ping_action_response_version_arbitrary():
server = AlpineBitsServer()
with open("test/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
request_xml = f.read()
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
response = await server.handle_request(
@@ -91,7 +87,7 @@ async def test_ping_action_response_version_arbitrary():
@pytest.mark.asyncio
async def test_ping_action_response_invalid_action():
server = AlpineBitsServer()
with open("test/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
request_xml = f.read()
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
response = await server.handle_request(