|
1 | | -from datetime import UTC, datetime |
| 1 | +from datetime import datetime, timedelta, timezone |
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
@@ -126,10 +126,12 @@ def test_embed_color(session: Session, level: str, expected_color: int) -> None: |
126 | 126 |
|
127 | 127 | def test_embed_fields_start_time(session: Session) -> None: |
128 | 128 | """Test the 'Start Time' field of the embed.""" |
| 129 | + start_time = datetime(2024, 1, 2, 3, 4, 5, tzinfo=timezone(timedelta(hours=6))) |
| 130 | + session = session.model_copy(update={"start": start_time}) |
| 131 | + |
129 | 132 | embed = session_to_embed.create_session_embed(session, None) |
130 | 133 | assert embed.fields[0].name == "Start Time" |
131 | | - assert embed.fields[0].value.startswith("<t:") |
132 | | - assert embed.fields[0].value.endswith(":f>") |
| 134 | + assert embed.fields[0].value == f"<t:{int(start_time.timestamp())}>" |
133 | 135 |
|
134 | 136 |
|
135 | 137 | def test_embed_fields_room(session: Session) -> None: |
@@ -252,19 +254,6 @@ def test_embed_footer(session: Session) -> None: |
252 | 254 | assert embed.footer.text == "This session starts at 08:00:00 (local conference time)" |
253 | 255 |
|
254 | 256 |
|
255 | | -def test_format_start_time(session: Session) -> None: |
256 | | - """Test the _format_start_time function.""" |
257 | | - formatted_start_time = session_to_embed._format_start_time(session.start) |
258 | | - assert formatted_start_time.startswith("<t:") |
259 | | - assert formatted_start_time.endswith(":f>") |
260 | | - |
261 | | - # The following code assumes that the start time in the mock data is in UTC. |
262 | | - datetime_obj = datetime.fromtimestamp( |
263 | | - int(formatted_start_time.replace("<t:", "").replace(":f>", "")), tz=UTC |
264 | | - ) |
265 | | - assert datetime_obj == session.start |
266 | | - |
267 | | - |
268 | 257 | def test_format_duration(session: Session) -> None: |
269 | 258 | """Test the _format_duration function.""" |
270 | 259 | formatted_duration = session_to_embed._format_duration(session.duration) |
|
0 commit comments