Skip to content

Commit

Permalink
Tests: add test for new Event attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
elliot-100 committed Jul 13, 2024
1 parent 45eac6a commit 76ae9a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Historic and pre-release versions aren't necessarily included.
### Added

- `Event` attributes: `cancelled`, `created_time`, `end_time`, `invite_time`, `type`,
property `url`. Tests and docs pending.
property `url`. Docs pending.

### Changed

Expand Down
11 changes: 9 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ def simple_event_data() -> dict:
Item from 'events' (root).
"""
return {
"id": "A390CE5396D2F5C3015F53E171EC59D5",
"id": "E001",
"heading": "Event 1",
"type": "EVENT",
"responses": {
"acceptedIds": [],
"declinedIds": [],
"unansweredIds": [],
"waitinglistIds": [],
"unconfirmedIds": [],
},
"createdTime": "2020-12-31T19:00:00Z",
"endTimestamp": "2024-08-15T11:00:00Z",
"startTimestamp": "2021-07-06T06:00:00Z",
}

Expand All @@ -180,8 +183,10 @@ def complex_event_data() -> dict:
Item from 'events' (root).
"""
return {
"id": "36D7F1A46EB2CDED4B6F22D400229822",
"id": "E002",
"cancelled": "True",
"heading": "Event 2",
"type": "RECURRING",
"responses": {
"acceptedIds": [
"B24FA75A4CCBC63199A57361E88B0646",
Expand All @@ -199,5 +204,7 @@ def complex_event_data() -> dict:
"2D1BB37608F09511FD5F280D219DFD97",
],
},
"createdTime": "2019-04-24T19:00:00Z",
"endTimestamp": "2024-08-15T11:00:00Z",
"startTimestamp": "2022-11-04T06:00:00Z",
}
19 changes: 14 additions & 5 deletions tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from datetime import datetime, timezone

from spond_classes import Event
from spond_classes import Event, EventType


def test_from_dict_simple(simple_event_data: dict) -> None:
Expand All @@ -12,17 +12,21 @@ def test_from_dict_simple(simple_event_data: dict) -> None:
"""
my_event = Event(**simple_event_data)

assert my_event.uid == "A390CE5396D2F5C3015F53E171EC59D5"
assert my_event.uid == "E001"
assert my_event.heading == "Event 1"
assert my_event.type is EventType.EVENT
assert my_event.url == "https://spond.com/client/sponds/E001/"
assert my_event.responses.accepted_uids == []
assert my_event.responses.declined_uids == []
assert my_event.responses.unanswered_uids == []
assert my_event.responses.waiting_list_uids == []
assert my_event.responses.unconfirmed_uids == []
assert my_event.created_time == datetime(2020, 12, 31, 19, 0, tzinfo=timezone.utc)
assert my_event.end_time == datetime(2024, 8, 15, 11, 0, tzinfo=timezone.utc)
assert my_event.start_time == datetime(2021, 7, 6, 6, 0, tzinfo=timezone.utc)
assert str(my_event) == (
"Event("
"uid='A390CE5396D2F5C3015F53E171EC59D5', "
"uid='E001', "
"heading='Event 1', "
"start_time: 2021-07-06 06:00:00+00:00, "
"…)"
Expand All @@ -36,8 +40,11 @@ def test_from_dict_complex(complex_event_data: dict) -> None:
"""
my_event = Event(**complex_event_data)

assert my_event.uid == "36D7F1A46EB2CDED4B6F22D400229822"
assert my_event.uid == "E002"
assert my_event.cancelled is True
assert my_event.heading == "Event 2"
assert my_event.type is EventType.RECURRING
assert my_event.url == "https://spond.com/client/sponds/E002/"
assert my_event.responses.accepted_uids == [
"B24FA75A4CCBC63199A57361E88B0646",
]
Expand All @@ -53,10 +60,12 @@ def test_from_dict_complex(complex_event_data: dict) -> None:
assert my_event.responses.unconfirmed_uids == [
"2D1BB37608F09511FD5F280D219DFD97",
]
assert my_event.created_time == datetime(2019, 4, 24, 19, 0, tzinfo=timezone.utc)
assert my_event.end_time == datetime(2024, 8, 15, 11, 0, tzinfo=timezone.utc)
assert my_event.start_time == datetime(2022, 11, 4, 6, 0, tzinfo=timezone.utc)
assert str(my_event) == (
"Event("
"uid='36D7F1A46EB2CDED4B6F22D400229822', "
"uid='E002', "
"heading='Event 2', "
"start_time: 2022-11-04 06:00:00+00:00, "
"…)"
Expand Down

0 comments on commit 76ae9a0

Please sign in to comment.