forked from pushingkarmaorg/python-plexapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_photo.py
More file actions
96 lines (70 loc) · 2.93 KB
/
test_photo.py
File metadata and controls
96 lines (70 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
from urllib.parse import quote_plus
import pytest
from . import test_media, test_mixins
def test_photo_Photoalbum(photoalbum):
assert len(photoalbum.albums()) == 3
assert len(photoalbum.photos()) == 3
cats_in_bed = photoalbum.album("Cats in bed")
assert len(cats_in_bed.photos()) == 7
a_pic = cats_in_bed.photo("photo7")
assert a_pic
@pytest.mark.xfail(reason="Changing images fails randomly")
def test_photo_Photoalbum_mixins_images(photoalbum):
# test_mixins.lock_art(photoalbum) # Unlocking photoalbum artwork is broken in Plex
# test_mixins.lock_poster(photoalbum) # Unlocking photoalbum poster is broken in Plex
test_mixins.edit_art(photoalbum)
test_mixins.edit_poster(photoalbum)
test_mixins.lock_square_art(photoalbum)
test_mixins.attr_artUrl(photoalbum)
test_mixins.attr_posterUrl(photoalbum)
test_mixins.attr_squareArtUrl(photoalbum)
def test_photo_Photoalbum_mixins_rating(photoalbum):
test_mixins.edit_rating(photoalbum)
def test_photo_Photoalbum_mixins_fields(photoalbum):
test_mixins.edit_added_at(photoalbum)
test_mixins.edit_sort_title(photoalbum)
test_mixins.edit_summary(photoalbum)
test_mixins.edit_title(photoalbum)
test_mixins.edit_user_rating(photoalbum)
def test_photo_Photoalbum_PlexWebURL(plex, photoalbum):
url = photoalbum.getWebURL()
assert url.startswith('https://app.plex.tv/desktop')
assert plex.machineIdentifier in url
assert 'details' in url
assert quote_plus(photoalbum.key) in url
assert 'legacy=1' in url
def test_photo_Photo_mixins_rating(photo):
test_mixins.edit_rating(photo)
def test_photo_Photo_mixins_fields(photo):
test_mixins.edit_added_at(photo)
test_mixins.edit_sort_title(photo)
test_mixins.edit_summary(photo)
test_mixins.edit_title(photo)
test_mixins.edit_photo_captured_time(photo)
test_mixins.edit_user_rating(photo)
def test_photo_Photo_mixins_tags(photo):
test_mixins.edit_tag(photo)
def test_photo_Photo_media_tags(photo):
photo.reload()
test_media.tag_tag(photo)
def test_photo_Photo_PlexWebURL(plex, photo):
url = photo.getWebURL()
assert url.startswith('https://app.plex.tv/desktop')
assert plex.machineIdentifier in url
assert 'details' in url
assert quote_plus(photo.parentKey) in url
assert 'legacy=1' in url
def test_photo_Photoalbum_download(monkeydownload, tmpdir, photoalbum):
total = 0
for album in photoalbum.albums():
total += len(album.photos()) + len(album.clips())
total += len(photoalbum.photos())
total += len(photoalbum.clips())
filepaths = photoalbum.download(savepath=str(tmpdir))
assert len(filepaths) == total
subfolders = photoalbum.download(savepath=str(tmpdir), subfolders=True)
assert len(subfolders) == total
def test_photo_Photo_download(monkeydownload, tmpdir, photo):
filepaths = photo.download(savepath=str(tmpdir))
assert len(filepaths) == 1