Beispiel #1
0
    def test_play_media(self, mock_seek):
        """Test play_media ."""
        assert setup_component(self.hass, mp.DOMAIN,
                               {'media_player': {
                                   'platform': 'demo'
                               }})
        ent_id = 'media_player.living_room'
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA
                    & state.attributes.get('supported_features'))
        assert state.attributes.get('media_content_id') is not None

        common.play_media(self.hass, None, 'some_id', ent_id)
        self.hass.block_till_done()
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA
                    & state.attributes.get('supported_features'))
        assert not 'some_id' == state.attributes.get('media_content_id')

        common.play_media(self.hass, 'youtube', 'some_id', ent_id)
        self.hass.block_till_done()
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA
                    & state.attributes.get('supported_features'))
        assert 'some_id' == state.attributes.get('media_content_id')

        assert not mock_seek.called
        common.media_seek(self.hass, None, ent_id)
        self.hass.block_till_done()
        assert not mock_seek.called
        common.media_seek(self.hass, 100, ent_id)
        self.hass.block_till_done()
        assert mock_seek.called
Beispiel #2
0
    def test_play_media(self, mock_seek):
        """Test play_media ."""
        assert setup_component(
            self.hass, mp.DOMAIN,
            {'media_player': {'platform': 'demo'}})
        ent_id = 'media_player.living_room'
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA &
                    state.attributes.get('supported_features'))
        assert state.attributes.get('media_content_id') is not None

        with pytest.raises(vol.Invalid):
            common.play_media(self.hass, None, 'some_id', ent_id)
        self.hass.block_till_done()
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA &
                    state.attributes.get('supported_features'))
        assert not 'some_id' == state.attributes.get('media_content_id')

        common.play_media(self.hass, 'youtube', 'some_id', ent_id)
        self.hass.block_till_done()
        state = self.hass.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA &
                    state.attributes.get('supported_features'))
        assert 'some_id' == state.attributes.get('media_content_id')

        assert not mock_seek.called
        with pytest.raises(vol.Invalid):
            common.media_seek(self.hass, None, ent_id)
        self.hass.block_till_done()
        assert not mock_seek.called
        common.media_seek(self.hass, 100, ent_id)
        self.hass.block_till_done()
        assert mock_seek.called
Beispiel #3
0
 def test_seek(self, mock_seek):
     """Test seek."""
     assert setup_component(
         self.hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
     )
     ent_id = "media_player.living_room"
     state = self.hass.states.get(ent_id)
     assert state.attributes["supported_features"] & mp.SUPPORT_SEEK
     assert not mock_seek.called
     with pytest.raises(vol.Invalid):
         common.media_seek(self.hass, None, ent_id)
     self.hass.block_till_done()
     assert not mock_seek.called
     common.media_seek(self.hass, 100, ent_id)
     self.hass.block_till_done()
     assert mock_seek.called