Example #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

        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
Example #2
0
    def test_play_media(self):
        """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')
Example #3
0
    def test_play_media(self):
        """Test play_media ."""
        assert setup_component(self.opp, mp.DOMAIN,
                               {"media_player": {
                                   "platform": "demo"
                               }})
        ent_id = "media_player.living_room"
        state = self.opp.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.opp, None, "some_id", ent_id)
        self.opp.block_till_done()
        state = self.opp.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.opp, "youtube", "some_id", ent_id)
        self.opp.block_till_done()
        state = self.opp.states.get(ent_id)
        assert 0 < (mp.SUPPORT_PLAY_MEDIA
                    & state.attributes.get("supported_features"))
        assert "some_id" == state.attributes.get("media_content_id")