mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-24 20:53:09 +00:00
feat: add PlexPartialObject.isLocked method (#1293)
Co-authored-by: JonnyWong16 <9099342+jonnywong16@users.noreply.github.com>
This commit is contained in:
parent
70b126f477
commit
e0a425fdcb
3 changed files with 14 additions and 0 deletions
|
@ -565,6 +565,14 @@ class PlexPartialObject(PlexObject):
|
|||
""" Returns True if this is not a full object. """
|
||||
return not self.isFullObject()
|
||||
|
||||
def isLocked(self, field: str):
|
||||
""" Returns True if the specified field is locked, otherwise False.
|
||||
|
||||
Parameters:
|
||||
field (str): The name of the field.
|
||||
"""
|
||||
return next((f.locked for f in self.fields if f.name == field), False)
|
||||
|
||||
def _edit(self, **kwargs):
|
||||
""" Actually edit an object. """
|
||||
if isinstance(self._edits, dict):
|
||||
|
|
|
@ -190,6 +190,8 @@ def test_Collection_edit(collection, movies):
|
|||
assert collection.summary == newSummary
|
||||
lockedFields = [f.locked for f in collection.fields if f.name in fields]
|
||||
assert all(lockedFields)
|
||||
for f in fields:
|
||||
assert collection.isLocked(field=f)
|
||||
|
||||
collection.edit(
|
||||
title=title,
|
||||
|
@ -210,6 +212,8 @@ def test_Collection_edit(collection, movies):
|
|||
assert collection.summary == summary
|
||||
lockedFields = [f.locked for f in collection.fields if f.name in fields]
|
||||
assert not any(lockedFields)
|
||||
for f in fields:
|
||||
assert not collection.isLocked(field=f)
|
||||
|
||||
|
||||
def test_Collection_create(plex, tvshows):
|
||||
|
|
|
@ -1411,6 +1411,7 @@ def test_video_edits_locked(movie, episode):
|
|||
if field.name == 'titleSort':
|
||||
assert movie.titleSort == 'New Title Sort'
|
||||
assert field.locked is True
|
||||
assert movie.isLocked(field=field.name)
|
||||
movie.edit(**{'titleSort.value': movieTitleSort, 'titleSort.locked': 0})
|
||||
|
||||
episodeTitleSort = episode.titleSort
|
||||
|
@ -1420,6 +1421,7 @@ def test_video_edits_locked(movie, episode):
|
|||
if field.name == 'titleSort':
|
||||
assert episode.titleSort == 'New Title Sort'
|
||||
assert field.locked is True
|
||||
assert episode.isLocked(field=field.name)
|
||||
episode.edit(**{'titleSort.value': episodeTitleSort, 'titleSort.locked': 0})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue