コード例 #1
0
ファイル: TestPlexApi.py プロジェクト: ToonDoom/PlexPlugin
    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))
コード例 #2
0
ファイル: TestPlexApi.py プロジェクト: PlexHaxx/PlexPlugin
    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))
コード例 #3
0
ファイル: TestPlexApi.py プロジェクト: ToonDoom/PlexPlugin
    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])
コード例 #4
0
ファイル: TestPlexApi.py プロジェクト: ToonDoom/PlexPlugin
    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)
コード例 #5
0
ファイル: TestPlexApi.py プロジェクト: PlexHaxx/PlexPlugin
    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])
コード例 #6
0
ファイル: TestPlexApi.py プロジェクト: PlexHaxx/PlexPlugin
    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)