2021-02-15 06:58:48 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-08-04 21:02:01 +00:00
|
|
|
from urllib.parse import quote_plus
|
|
|
|
|
2021-11-21 01:14:34 +00:00
|
|
|
import pytest
|
|
|
|
|
2021-05-09 22:05:06 +00:00
|
|
|
from . import test_media, test_mixins
|
2021-02-15 06:58:48 +00:00
|
|
|
|
|
|
|
|
2017-10-25 18:58:20 +00:00
|
|
|
def test_photo_Photoalbum(photoalbum):
|
|
|
|
assert len(photoalbum.albums()) == 3
|
|
|
|
assert len(photoalbum.photos()) == 3
|
2020-04-29 21:23:22 +00:00
|
|
|
cats_in_bed = photoalbum.album("Cats in bed")
|
2017-10-25 18:58:20 +00:00
|
|
|
assert len(cats_in_bed.photos()) == 7
|
2020-04-29 21:23:22 +00:00
|
|
|
a_pic = cats_in_bed.photo("photo7")
|
2017-10-25 18:58:20 +00:00
|
|
|
assert a_pic
|
2021-02-15 06:58:48 +00:00
|
|
|
|
|
|
|
|
2021-11-21 01:14:34 +00:00
|
|
|
@pytest.mark.xfail(reason="Changing images fails randomly")
|
2021-02-15 06:58:48 +00:00
|
|
|
def test_photo_Photoalbum_mixins_images(photoalbum):
|
2021-09-13 00:56:21 +00:00
|
|
|
# test_mixins.lock_art(photoalbum) # Unlocking photoalbum artwork is broken in Plex
|
|
|
|
# test_mixins.lock_poster(photoalbum) # Unlocking photoalbum poster is broken in Plex
|
2021-02-15 06:58:48 +00:00
|
|
|
test_mixins.edit_art(photoalbum)
|
|
|
|
test_mixins.edit_poster(photoalbum)
|
|
|
|
test_mixins.attr_artUrl(photoalbum)
|
|
|
|
test_mixins.attr_posterUrl(photoalbum)
|
|
|
|
|
|
|
|
|
2021-05-30 22:49:28 +00:00
|
|
|
def test_photo_Photoalbum_mixins_rating(photoalbum):
|
|
|
|
test_mixins.edit_rating(photoalbum)
|
|
|
|
|
|
|
|
|
2022-02-27 05:40:51 +00:00
|
|
|
def test_photo_Photoalbum_mixins_fields(photoalbum):
|
|
|
|
test_mixins.edit_sort_title(photoalbum)
|
|
|
|
test_mixins.edit_summary(photoalbum)
|
|
|
|
test_mixins.edit_title(photoalbum)
|
|
|
|
|
|
|
|
|
2021-11-20 22:16:58 +00:00
|
|
|
def test_photo_Photoalbum_PlexWebURL(plex, photoalbum):
|
2021-08-04 21:02:01 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2021-05-30 22:49:28 +00:00
|
|
|
def test_photo_Photo_mixins_rating(photo):
|
|
|
|
test_mixins.edit_rating(photo)
|
|
|
|
|
|
|
|
|
2022-02-27 05:40:51 +00:00
|
|
|
def test_photo_Photo_mixins_fields(photo):
|
|
|
|
test_mixins.edit_sort_title(photo)
|
|
|
|
test_mixins.edit_summary(photo)
|
|
|
|
test_mixins.edit_title(photo)
|
|
|
|
test_mixins.edit_photo_captured_time(photo)
|
|
|
|
|
|
|
|
|
2021-02-15 06:58:48 +00:00
|
|
|
def test_photo_Photo_mixins_tags(photo):
|
|
|
|
test_mixins.edit_tag(photo)
|
2021-05-09 22:05:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_photo_Photo_media_tags(photo):
|
|
|
|
photo.reload()
|
|
|
|
test_media.tag_tag(photo)
|
2021-08-04 21:02:01 +00:00
|
|
|
|
|
|
|
|
2021-11-20 22:16:58 +00:00
|
|
|
def test_photo_Photo_PlexWebURL(plex, photo):
|
2021-08-04 21:02:01 +00:00
|
|
|
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
|
2021-11-20 22:16:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|