Update tests for ratings mixin

This commit is contained in:
JonnyWong16 2021-05-30 15:49:28 -07:00
parent 6e58f7f70e
commit bd8cdb10b7
6 changed files with 59 additions and 10 deletions

View file

@ -19,12 +19,3 @@ def test_refresh_section(tvshows):
def test_refresh_video(movie): def test_refresh_video(movie):
movie.refresh() movie.refresh()
def test_rate_movie(movie):
oldrate = movie.userRating
if oldrate is None:
oldrate = 1
movie.rate(10.0)
assert movie.userRating == 10.0, 'User rating 10.0 after rating five stars.'
movie.rate(oldrate)

View file

@ -80,6 +80,10 @@ def test_audio_Artist_mixins_images(artist):
test_mixins.attr_posterUrl(artist) test_mixins.attr_posterUrl(artist)
def test_audio_Artist_mixins_rating(artist):
test_mixins.edit_rating(artist)
def test_audio_Artist_mixins_tags(artist): def test_audio_Artist_mixins_tags(artist):
test_mixins.edit_collection(artist) test_mixins.edit_collection(artist)
test_mixins.edit_country(artist) test_mixins.edit_country(artist)
@ -171,6 +175,10 @@ def test_audio_Album_mixins_images(album):
test_mixins.attr_posterUrl(album) test_mixins.attr_posterUrl(album)
def test_audio_Album_mixins_rating(album):
test_mixins.edit_rating(album)
def test_audio_Album_mixins_tags(album): def test_audio_Album_mixins_tags(album):
test_mixins.edit_collection(album) test_mixins.edit_collection(album)
test_mixins.edit_genre(album) test_mixins.edit_genre(album)
@ -314,6 +322,10 @@ def test_audio_Track_mixins_images(track):
test_mixins.attr_posterUrl(track) test_mixins.attr_posterUrl(track)
def test_audio_Track_mixins_rating(track):
test_mixins.edit_rating(track)
def test_audio_Track_mixins_tags(track): def test_audio_Track_mixins_tags(track):
test_mixins.edit_collection(track) test_mixins.edit_collection(track)
test_mixins.edit_mood(track) test_mixins.edit_mood(track)

View file

@ -114,5 +114,9 @@ def test_Collection_mixins_images(collection):
test_mixins.attr_posterUrl(collection) test_mixins.attr_posterUrl(collection)
def test_Collection_mixins_rating(collection):
test_mixins.edit_rating(collection)
def test_Collection_mixins_tags(collection): def test_Collection_mixins_tags(collection):
test_mixins.edit_label(collection) test_mixins.edit_label(collection)

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from plexapi.exceptions import NotFound from plexapi.exceptions import BadRequest, NotFound
from plexapi.utils import tag_singular from plexapi.utils import tag_singular
import pytest import pytest
@ -177,3 +177,20 @@ def edit_advanced_settings(obj):
_test_mixins_editAdvanced(obj) _test_mixins_editAdvanced(obj)
_test_mixins_editAdvanced_bad_pref(obj) _test_mixins_editAdvanced_bad_pref(obj)
_test_mixins_defaultAdvanced(obj) _test_mixins_defaultAdvanced(obj)
def edit_rating(obj):
obj.rate(10.0)
obj.reload()
assert utils.is_datetime(obj.lastRatedAt)
assert obj.userRating == 10.0
obj.rate()
obj.reload()
assert obj.lastRatedAt is None
assert obj.userRating is None
with pytest.raises(BadRequest):
assert obj.rate('bad-rating')
with pytest.raises(BadRequest):
assert obj.rate(-1)
with pytest.raises(BadRequest):
assert obj.rate(100)

View file

@ -18,6 +18,14 @@ def test_photo_Photoalbum_mixins_images(photoalbum):
test_mixins.attr_posterUrl(photoalbum) test_mixins.attr_posterUrl(photoalbum)
def test_photo_Photoalbum_mixins_rating(photoalbum):
test_mixins.edit_rating(photoalbum)
def test_photo_Photo_mixins_rating(photo):
test_mixins.edit_rating(photo)
def test_photo_Photo_mixins_tags(photo): def test_photo_Photo_mixins_tags(photo):
test_mixins.edit_tag(photo) test_mixins.edit_tag(photo)

View file

@ -49,6 +49,10 @@ def test_video_Movie_mixins_images(movie):
test_mixins.edit_poster(movie) test_mixins.edit_poster(movie)
def test_video_Movie_mixins_rating(movie):
test_mixins.edit_rating(movie)
def test_video_Movie_mixins_tags(movie): def test_video_Movie_mixins_tags(movie):
test_mixins.edit_collection(movie) test_mixins.edit_collection(movie)
test_mixins.edit_country(movie) test_mixins.edit_country(movie)
@ -729,6 +733,10 @@ def test_video_Show_mixins_images(show):
test_mixins.attr_posterUrl(show) test_mixins.attr_posterUrl(show)
def test_video_Show_mixins_rating(show):
test_mixins.edit_rating(show)
def test_video_Show_mixins_tags(show): def test_video_Show_mixins_tags(show):
test_mixins.edit_collection(show) test_mixins.edit_collection(show)
test_mixins.edit_genre(show) test_mixins.edit_genre(show)
@ -843,6 +851,11 @@ def test_video_Season_mixins_images(show):
test_mixins.attr_posterUrl(season) test_mixins.attr_posterUrl(season)
def test_video_Season_mixins_rating(show):
season = show.season(season=1)
test_mixins.edit_rating(season)
def test_video_Season_mixins_tags(show): def test_video_Season_mixins_tags(show):
season = show.season(season=1) season = show.season(season=1)
test_mixins.edit_collection(season) test_mixins.edit_collection(season)
@ -1033,6 +1046,10 @@ def test_video_Episode_mixins_images(episode):
test_mixins.attr_posterUrl(episode) test_mixins.attr_posterUrl(episode)
def test_video_Episode_mixins_rating(episode):
test_mixins.edit_rating(episode)
def test_video_Episode_mixins_tags(episode): def test_video_Episode_mixins_tags(episode):
test_mixins.edit_collection(episode) test_mixins.edit_collection(episode)
test_mixins.edit_director(episode) test_mixins.edit_director(episode)