33from urllib .parse import quote_plus
44
55import pytest
6- from datetime import datetime
6+ from datetime import datetime , timedelta
77from PIL import Image
88from plexapi .exceptions import BadRequest , NotFound
99from plexapi .server import PlexServer
10- from plexapi .utils import download
10+ from plexapi .utils import download , setDatetimeTimezone , DATETIME_TIMEZONE
1111from requests import Session
1212
1313from . import conftest as utils
@@ -32,6 +32,32 @@ def test_server_attr(plex, account):
3232 assert len (plex .version ) >= 5
3333
3434
35+ def test_server_updatedAt_timezone (plex ):
36+ original = DATETIME_TIMEZONE
37+ try :
38+ # no timezone configured, should be naive
39+ setDatetimeTimezone (False )
40+ dt_naive = plex .updatedAt
41+ assert dt_naive .tzinfo is None
42+
43+ # local timezone configured, should be aware
44+ setDatetimeTimezone (True )
45+ dt_local = plex .updatedAt
46+ assert dt_local .tzinfo is not None
47+
48+ # explicit IANA zones. Check that the offset is correct too
49+ setDatetimeTimezone ("UTC" )
50+ dt : datetime = plex .updatedAt
51+ assert dt .tzinfo is not None
52+ assert dt .tzinfo .utcoffset (dt ) == timedelta (0 )
53+ setDatetimeTimezone ("Asia/Dubai" )
54+ dt : datetime = plex .updatedAt
55+ assert dt .tzinfo is not None
56+ assert dt .tzinfo .utcoffset (dt ) == timedelta (hours = 4 )
57+ finally : # Restore for other tests
58+ setDatetimeTimezone (original )
59+
60+
3561def test_server_alert_listener (plex , movies ):
3662 try :
3763 messages = []
0 commit comments