feat: add PlexPartialObject.isLocked method (#1293)

Co-authored-by: JonnyWong16 <9099342+jonnywong16@users.noreply.github.com>
This commit is contained in:
ReenigneArcher 2023-11-13 13:56:30 -05:00 committed by GitHub
parent 70b126f477
commit e0a425fdcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View file

@ -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):

View file

@ -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):

View file

@ -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})