Skip to content

Commit cee2277

Browse files
committed
Test party serialization
1 parent 00ce3da commit cee2277

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
- Added tests for party, series reading.
1414

15+
- Added tests for party serialization.
16+
1517
- Added ruff as a development dependency.
1618

1719

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
:Copyright: 2024 Jochen Kupperschmidt
3+
:License: MIT
4+
"""
5+
6+
from datetime import date
7+
from textwrap import dedent
8+
9+
import pytest
10+
11+
from lanpartydb.models import Links, Location, Party, Resource
12+
from lanpartydb.writing import serialize_party
13+
14+
15+
@pytest.mark.parametrize(
16+
('party', 'expected'),
17+
[
18+
(
19+
Party(
20+
slug='megalan-2023',
21+
title='MegaLAN 2023',
22+
start_on=date(2023, 11, 17),
23+
end_on=date(2023, 11, 19),
24+
),
25+
dedent("""\
26+
slug = "megalan-2023"
27+
title = "MegaLAN 2023"
28+
start_on = 2023-11-17
29+
end_on = 2023-11-19
30+
"""),
31+
),
32+
(
33+
Party(
34+
slug='superlan-2024',
35+
title='SuperLAN 2024',
36+
series_slug='superlan',
37+
organizer_entity='SuperLAN Association',
38+
start_on=date(2024, 5, 24),
39+
end_on=date(2024, 5, 26),
40+
seats=420,
41+
attendees=397,
42+
online=False,
43+
location=Location(
44+
name='City Hall',
45+
country_code='us',
46+
city='Los Angeles',
47+
zip_code='90099',
48+
street='123 North Hill Street',
49+
),
50+
links=Links(
51+
website=Resource(
52+
url='https://www.superlan.example/',
53+
offline=False,
54+
),
55+
),
56+
),
57+
dedent("""\
58+
slug = "superlan-2024"
59+
title = "SuperLAN 2024"
60+
series_slug = "superlan"
61+
organizer_entity = "SuperLAN Association"
62+
start_on = 2024-05-24
63+
end_on = 2024-05-26
64+
seats = 420
65+
attendees = 397
66+
67+
[location]
68+
name = "City Hall"
69+
country_code = "us"
70+
city = "Los Angeles"
71+
zip_code = "90099"
72+
street = "123 North Hill Street"
73+
74+
[links.website]
75+
url = "https://www.superlan.example/"
76+
"""),
77+
),
78+
],
79+
)
80+
def test_serialize_party(party: Party, expected: str):
81+
assert serialize_party(party) == expected

0 commit comments

Comments
 (0)