@@ -78,7 +78,34 @@ def edit_writer(obj):
7878 _test_mixins_tag (obj , "writers" , "Writer" )
7979
8080
81- def _test_mixins_image (obj , attr ):
81+ def _test_mixins_lock_image (obj , attr ):
82+ cap_attr = attr [:- 1 ].capitalize ()
83+ lock_img_method = getattr (obj , "lock" + cap_attr )
84+ unlock_img_method = getattr (obj , "unlock" + cap_attr )
85+ field = "thumb" if attr == 'posters' else attr [:- 1 ]
86+ _fields = lambda : [f .name for f in obj .fields ]
87+ assert field not in _fields ()
88+ lock_img_method ()
89+ obj .reload ()
90+ assert field in _fields ()
91+ unlock_img_method ()
92+ obj .reload ()
93+ assert field not in _fields ()
94+
95+
96+ def lock_art (obj ):
97+ _test_mixins_lock_image (obj , "arts" )
98+
99+
100+ def lock_banner (obj ):
101+ _test_mixins_lock_image (obj , "banners" )
102+
103+
104+ def lock_poster (obj ):
105+ _test_mixins_lock_image (obj , "posters" )
106+
107+
108+ def _test_mixins_edit_image (obj , attr ):
82109 cap_attr = attr [:- 1 ].capitalize ()
83110 get_img_method = getattr (obj , attr )
84111 set_img_method = getattr (obj , "set" + cap_attr )
@@ -106,7 +133,7 @@ def _test_mixins_image(obj, attr):
106133 images = get_img_method ()
107134 file_image = [
108135 i for i in images
109- if i .ratingKey .startswith (' upload://' ) and i .ratingKey .endswith (CUTE_CAT_SHA1 )
136+ if i .ratingKey .startswith (" upload://" ) and i .ratingKey .endswith (CUTE_CAT_SHA1 )
110137 ]
111138 assert file_image
112139 # Reset to default image
@@ -115,39 +142,39 @@ def _test_mixins_image(obj, attr):
115142
116143
117144def edit_art (obj ):
118- _test_mixins_image (obj , ' arts' )
145+ _test_mixins_edit_image (obj , " arts" )
119146
120147
121148def edit_banner (obj ):
122- _test_mixins_image (obj , ' banners' )
149+ _test_mixins_edit_image (obj , " banners" )
123150
124151
125152def edit_poster (obj ):
126- _test_mixins_image (obj , ' posters' )
153+ _test_mixins_edit_image (obj , " posters" )
127154
128155
129156def _test_mixins_imageUrl (obj , attr ):
130- url = getattr (obj , attr + ' Url' )
157+ url = getattr (obj , attr + " Url" )
131158 if getattr (obj , attr ):
132159 assert url .startswith (utils .SERVER_BASEURL )
133160 assert "/library/metadata/" in url or "/library/collections/" in url
134161 assert attr in url or "composite" in url
135- if attr == ' thumb' :
136- assert getattr (obj , ' posterUrl' ) == url
162+ if attr == " thumb" :
163+ assert getattr (obj , " posterUrl" ) == url
137164 else :
138165 assert url is None
139166
140167
141168def attr_artUrl (obj ):
142- _test_mixins_imageUrl (obj , ' art' )
169+ _test_mixins_imageUrl (obj , " art" )
143170
144171
145172def attr_bannerUrl (obj ):
146- _test_mixins_imageUrl (obj , ' banner' )
173+ _test_mixins_imageUrl (obj , " banner" )
147174
148175
149176def attr_posterUrl (obj ):
150- _test_mixins_imageUrl (obj , ' thumb' )
177+ _test_mixins_imageUrl (obj , " thumb" )
151178
152179
153180def _test_mixins_editAdvanced (obj ):
@@ -163,7 +190,7 @@ def _test_mixins_editAdvanced(obj):
163190
164191def _test_mixins_editAdvanced_bad_pref (obj ):
165192 with pytest .raises (NotFound ):
166- assert obj .preference (' bad-pref' )
193+ assert obj .preference (" bad-pref" )
167194
168195
169196def _test_mixins_defaultAdvanced (obj ):
@@ -188,7 +215,7 @@ def edit_rating(obj):
188215 obj .reload ()
189216 assert obj .userRating is None
190217 with pytest .raises (BadRequest ):
191- assert obj .rate (' bad-rating' )
218+ assert obj .rate (" bad-rating" )
192219 with pytest .raises (BadRequest ):
193220 assert obj .rate (- 1 )
194221 with pytest .raises (BadRequest ):
0 commit comments