|
| 1 | +""" |
| 2 | +:Copyright: 2024 Jochen Kupperschmidt |
| 3 | +:License: MIT |
| 4 | +""" |
| 5 | + |
| 6 | +from datetime import date |
| 7 | +from decimal import Decimal |
| 8 | + |
| 9 | +import pytest |
| 10 | + |
| 11 | +from lanpartydb.models import Links, Location, Party, Resource |
| 12 | +from lanpartydb.reading import read_party_from_toml |
| 13 | + |
| 14 | + |
| 15 | +@pytest.mark.parametrize( |
| 16 | + ('toml', 'expected'), |
| 17 | + [ |
| 18 | + ( |
| 19 | + """ |
| 20 | + slug = "megalan-2023" |
| 21 | + title = "MegaLAN 2023" |
| 22 | + start_on = 2023-11-17 |
| 23 | + end_on = 2023-11-19 |
| 24 | + """, |
| 25 | + Party( |
| 26 | + slug='megalan-2023', |
| 27 | + title='MegaLAN 2023', |
| 28 | + series_slug=None, |
| 29 | + organizer_entity=None, |
| 30 | + start_on=date(2023, 11, 17), |
| 31 | + end_on=date(2023, 11, 19), |
| 32 | + seats=None, |
| 33 | + attendees=None, |
| 34 | + online=False, |
| 35 | + location=None, |
| 36 | + links=None, |
| 37 | + ), |
| 38 | + ), |
| 39 | + ( |
| 40 | + """ |
| 41 | + slug = "superlan-2024" |
| 42 | + title = "SuperLAN 2024" |
| 43 | + series_slug = "superlan" |
| 44 | + organizer_entity = "SuperLAN Association" |
| 45 | + start_on = 2024-05-24 |
| 46 | + end_on = 2024-05-26 |
| 47 | + seats = 420 |
| 48 | + attendees = 397 |
| 49 | +
|
| 50 | + [location] |
| 51 | + name = 'City Hall' |
| 52 | + country_code = 'us' |
| 53 | + city = 'Los Angeles' |
| 54 | + zip_code = "90099" |
| 55 | + street = "123 North Hill Street" |
| 56 | + latitude = 34.06101057935884 |
| 57 | + longitude = -118.23974355902666 |
| 58 | +
|
| 59 | + [links.website] |
| 60 | + url = "https://www.superlan.example/" |
| 61 | + """, |
| 62 | + Party( |
| 63 | + slug='superlan-2024', |
| 64 | + title='SuperLAN 2024', |
| 65 | + series_slug='superlan', |
| 66 | + organizer_entity='SuperLAN Association', |
| 67 | + start_on=date(2024, 5, 24), |
| 68 | + end_on=date(2024, 5, 26), |
| 69 | + seats=420, |
| 70 | + attendees=397, |
| 71 | + online=False, |
| 72 | + location=Location( |
| 73 | + name='City Hall', |
| 74 | + country_code='us', |
| 75 | + city='Los Angeles', |
| 76 | + zip_code='90099', |
| 77 | + street='123 North Hill Street', |
| 78 | + latitude=Decimal('34.06101057935884'), |
| 79 | + longitude=Decimal('-118.23974355902666'), |
| 80 | + ), |
| 81 | + links=Links( |
| 82 | + website=Resource( |
| 83 | + url='https://www.superlan.example/', |
| 84 | + offline=False, |
| 85 | + ), |
| 86 | + ), |
| 87 | + ), |
| 88 | + ), |
| 89 | + ], |
| 90 | +) |
| 91 | +def test_read_party_from_toml(toml: str, expected: Party): |
| 92 | + assert read_party_from_toml(toml) == expected |
0 commit comments