Skip to content

Commit e0a425f

Browse files
feat: add PlexPartialObject.isLocked method (#1293)
Co-authored-by: JonnyWong16 <[email protected]>
1 parent 70b126f commit e0a425f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

plexapi/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,14 @@ def isPartialObject(self):
565565
""" Returns True if this is not a full object. """
566566
return not self.isFullObject()
567567

568+
def isLocked(self, field: str):
569+
""" Returns True if the specified field is locked, otherwise False.
570+
571+
Parameters:
572+
field (str): The name of the field.
573+
"""
574+
return next((f.locked for f in self.fields if f.name == field), False)
575+
568576
def _edit(self, **kwargs):
569577
""" Actually edit an object. """
570578
if isinstance(self._edits, dict):

tests/test_collection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def test_Collection_edit(collection, movies):
190190
assert collection.summary == newSummary
191191
lockedFields = [f.locked for f in collection.fields if f.name in fields]
192192
assert all(lockedFields)
193+
for f in fields:
194+
assert collection.isLocked(field=f)
193195

194196
collection.edit(
195197
title=title,
@@ -210,6 +212,8 @@ def test_Collection_edit(collection, movies):
210212
assert collection.summary == summary
211213
lockedFields = [f.locked for f in collection.fields if f.name in fields]
212214
assert not any(lockedFields)
215+
for f in fields:
216+
assert not collection.isLocked(field=f)
213217

214218

215219
def test_Collection_create(plex, tvshows):

tests/test_video.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ def test_video_edits_locked(movie, episode):
14111411
if field.name == 'titleSort':
14121412
assert movie.titleSort == 'New Title Sort'
14131413
assert field.locked is True
1414+
assert movie.isLocked(field=field.name)
14141415
movie.edit(**{'titleSort.value': movieTitleSort, 'titleSort.locked': 0})
14151416

14161417
episodeTitleSort = episode.titleSort
@@ -1420,6 +1421,7 @@ def test_video_edits_locked(movie, episode):
14201421
if field.name == 'titleSort':
14211422
assert episode.titleSort == 'New Title Sort'
14221423
assert field.locked is True
1424+
assert episode.isLocked(field=field.name)
14231425
episode.edit(**{'titleSort.value': episodeTitleSort, 'titleSort.locked': 0})
14241426

14251427

0 commit comments

Comments
 (0)