Skip to content

Commit fa5cbcd

Browse files
committed
chore: Migrate tz tests from the server module to a less important video module as to not conflict with other tests
1 parent fcff93b commit fa5cbcd

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

tests/test_server.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from urllib.parse import quote_plus
44

55
import pytest
6-
from datetime import datetime, timedelta
6+
from datetime import datetime
77
from PIL import Image
88
from plexapi.exceptions import BadRequest, NotFound
99
from plexapi.server import PlexServer
10-
from plexapi.utils import download, setDatetimeTimezone, DATETIME_TIMEZONE
10+
from plexapi.utils import download
1111
from requests import Session
1212

1313
from . import conftest as utils
@@ -32,36 +32,6 @@ 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-
plex.reload()
41-
dt_naive = plex.updatedAt
42-
assert dt_naive.tzinfo is None
43-
44-
# local timezone configured, should be aware
45-
setDatetimeTimezone(True)
46-
plex.reload()
47-
dt_local = plex.updatedAt
48-
assert dt_local.tzinfo is not None
49-
50-
# explicit IANA zones. Check that the offset is correct too
51-
setDatetimeTimezone("UTC")
52-
plex.reload()
53-
dt: datetime = plex.updatedAt
54-
assert dt.tzinfo is not None
55-
assert dt.tzinfo.utcoffset(dt) == timedelta(0)
56-
setDatetimeTimezone("Asia/Dubai")
57-
plex.reload()
58-
dt: datetime = plex.updatedAt
59-
assert dt.tzinfo is not None
60-
assert dt.tzinfo.utcoffset(dt) == timedelta(hours=4)
61-
finally: # Restore for other tests
62-
setDatetimeTimezone(original)
63-
64-
6535
def test_server_alert_listener(plex, movies):
6636
try:
6737
messages = []

tests/test_video.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import os
2-
from datetime import datetime
2+
from datetime import datetime, timedelta
33
from time import sleep
44
from urllib.parse import quote_plus
55

66
import pytest
7+
import plexapi.utils as plexutils
78
from plexapi.exceptions import BadRequest, NotFound
9+
from plexapi.utils import setDatetimeTimezone
810
from plexapi.sync import VIDEO_QUALITY_3_MBPS_720p
911

1012
from . import conftest as utils
@@ -21,6 +23,37 @@ def test_video_Movie_attributeerror(movie):
2123
movie.asshat
2224

2325

26+
def test_video_Movie_datetime_timezone(movie):
27+
original = plexutils.DATETIME_TIMEZONE
28+
try:
29+
# no timezone configured, should be naive
30+
setDatetimeTimezone(False)
31+
movie.reload()
32+
dt_naive = movie.updatedAt
33+
assert dt_naive.tzinfo is None
34+
35+
# local timezone configured, should be aware
36+
setDatetimeTimezone(True)
37+
movie.reload()
38+
dt_local = movie.updatedAt
39+
assert dt_local.tzinfo is not None
40+
41+
# explicit IANA zones. Check that the offset is correct too
42+
setDatetimeTimezone("UTC")
43+
movie.reload()
44+
dt = movie.updatedAt
45+
assert dt.tzinfo is not None
46+
assert dt.tzinfo.utcoffset(dt) == timedelta(0)
47+
48+
setDatetimeTimezone("Asia/Dubai")
49+
movie.reload()
50+
dt = movie.updatedAt
51+
assert dt.tzinfo is not None
52+
assert dt.tzinfo.utcoffset(dt) == timedelta(hours=4)
53+
finally: # Restore for other tests
54+
setDatetimeTimezone(original)
55+
56+
2457
def test_video_ne(movies):
2558
assert (
2659
len(

0 commit comments

Comments
 (0)