def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs): indigo.PluginBase.__init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs) self.plexApi = PlexApi(pluginPrefs.get('address'), pluginPrefs.get('port')) self.debug = pluginPrefs.get('showDebugInfo', False)
def testGetClientMachineIds_no_results(self): real = PlexApi("foo", "bar") real.getStatusSession = Mock(return_value=''' <MediaContainer size="0"> </MediaContainer> ''') machineIds = real.getClientMachineIds() assert isinstance(machineIds, list) self.assertEqual(0, len(machineIds))
def testGetClientMachineIds(self): real = PlexApi("foo", "bar") machineId1 = '''TestMI1''' machineId2 = '''TestMI2''' real.getStatusSession = Mock(return_value=(''' <MediaContainer size="1"> <Video> <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" /> <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" /> </Video> </MediaContainer> ''' % (machineId1, machineId2))) machineIds = real.getClientMachineIds() assert isinstance(machineIds, list) self.assertEqual(2, len(machineIds)) self.assertEqual(machineId1, machineIds[0]) self.assertEqual(machineId2, machineIds[1])
def testGetClientState(self): real = PlexApi("foo", "bar") machineId1 = 'TestMI1' machineId2 = 'TestMI2' real.getStatusSession = Mock(return_value=(''' <MediaContainer size="1"> <Video> <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="paused" title="HTPC" /> <Player machineIdentifier="%s" platform="Plex Home Theater" product="Plex Home Theater" state="playing" title="HTPC" /> </Video> </MediaContainer> ''' % (machineId1, machineId2))) state = real.getClientState(machineId1) self.assertEqual('paused', state) state = real.getClientState(machineId2) self.assertEqual('playing', state) state = real.getClientState('unknownMI') self.assertEqual('client_offline', state)
def closedPrefsConfigUi(self, valuesDict, userCancelled): if not userCancelled: address = valuesDict.get(u"address") port = valuesDict.get(u"port") self.debugLog(u"Plex Server " + address + ":" + port) self.plexApi = PlexApi(address, port)