mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
one step closer with the test.
This commit is contained in:
parent
ff4b1010a9
commit
db3b729360
3 changed files with 33 additions and 7 deletions
|
@ -177,12 +177,13 @@ class PlexObject(object):
|
|||
results.append(elem.attrib.get(attr))
|
||||
return results
|
||||
|
||||
def reload(self):
|
||||
def reload(self, key=None):
|
||||
""" Reload the data for this object from self.key. """
|
||||
if not self.key:
|
||||
key = key or self.key
|
||||
if not key:
|
||||
raise Unsupported('Cannot reload an object not built from a URL.')
|
||||
self._initpath = self.key
|
||||
data = self._server.query(self.key)
|
||||
self._initpath = key
|
||||
data = self._server.query(key)
|
||||
self._loadData(data[0])
|
||||
return self
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class Library(PlexObject):
|
|||
for section in self.sections():
|
||||
section.deleteMediaPreviews()
|
||||
|
||||
def add(self, name='', media_type='', agent='', scanner='', location='', language='en', *args, **kwargs):
|
||||
def add(self, name='', type='', agent='', scanner='', location='', language='en', *args, **kwargs):
|
||||
""" Simplified add for the most common options.
|
||||
|
||||
name (str): Name of the library
|
||||
|
@ -227,9 +227,13 @@ class LibrarySection(PlexObject):
|
|||
def edit(self, **kwargs):
|
||||
"""Edit a library
|
||||
|
||||
See addLibrary for example usage.
|
||||
See :class:`~plexapi.library.Library for example usage.
|
||||
|
||||
Note: agent is required.
|
||||
|
||||
kwargs (dict): Dict of settings to edit. Some values might need to be quoted.
|
||||
Value of scanner, name and location is quoted automatically.
|
||||
|
||||
"""
|
||||
# We might need to quote more, but lets start with what we know.
|
||||
kw = {}
|
||||
|
@ -239,7 +243,12 @@ class LibrarySection(PlexObject):
|
|||
kw[k] = v
|
||||
|
||||
part = '/library/sections/%s?%s' % (self.key, urlencode(kw))
|
||||
return self._server.query(part, method=self._server._session.put)
|
||||
self._server.query(part, method=self._server._session.put)
|
||||
# Reload this way since the self.key dont have a full path, but is simply a id.
|
||||
for s in self._server.library.sections():
|
||||
if s.key == self.key:
|
||||
return s
|
||||
|
||||
|
||||
def get(self, title):
|
||||
""" Returns the media item with the specified title.
|
||||
|
|
|
@ -76,6 +76,22 @@ def test_library_search(pms):
|
|||
m = pms.library.search('16 blocks')[0]
|
||||
assert m.title == '16 Blocks'
|
||||
|
||||
def test_library_add_edit_delete(pms):
|
||||
d = dict(name='zomg strange11', type='movie', agent='com.plexapp.agents.imdb',
|
||||
scanner='Plex Movie Scanner', language='en')
|
||||
|
||||
rn = dict(name='a renamed lib', type='movie', agent='com.plexapp.agents.imdb')
|
||||
|
||||
# We dont want to add a location because we dont want to start scanning.
|
||||
pms.library.add(**d)
|
||||
|
||||
assert pms.library.section('zomg strange11')
|
||||
|
||||
edited_library = pms.library.section('zomg strange11').edit(**rn)
|
||||
assert edited_library.title == 'a renamed lib'
|
||||
|
||||
pms.library.section('a renamed lib').delete()
|
||||
|
||||
|
||||
def test_library_Library_cleanBundle(pms):
|
||||
pms.library.cleanBundles()
|
||||
|
|
Loading…
Reference in a new issue