Exemple #1
0
    def test_volume_services(self):
        """Test the volume service."""
        assert setup_component(self.opp, mp.DOMAIN,
                               {"media_player": {
                                   "platform": "demo"
                               }})
        state = self.opp.states.get(entity_id)
        assert 1.0 == state.attributes.get("volume_level")

        with pytest.raises(vol.Invalid):
            common.set_volume_level(self.opp, None, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert 1.0 == state.attributes.get("volume_level")

        common.set_volume_level(self.opp, 0.5, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert 0.5 == state.attributes.get("volume_level")

        common.volume_down(self.opp, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert 0.4 == state.attributes.get("volume_level")

        common.volume_up(self.opp, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert 0.5 == state.attributes.get("volume_level")

        assert False is state.attributes.get("is_volume_muted")

        with pytest.raises(vol.Invalid):
            common.mute_volume(self.opp, None, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert False is state.attributes.get("is_volume_muted")

        common.mute_volume(self.opp, True, entity_id)
        self.opp.block_till_done()
        state = self.opp.states.get(entity_id)
        assert True is state.attributes.get("is_volume_muted")
    def test_volume_services(self):
        """Test the volume service."""
        assert setup_component(self.hass, mp.DOMAIN,
                               {'media_player': {
                                   'platform': 'demo'
                               }})
        state = self.hass.states.get(entity_id)
        assert 1.0 == state.attributes.get('volume_level')

        with pytest.raises(vol.Invalid):
            common.set_volume_level(self.hass, None, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 1.0 == state.attributes.get('volume_level')

        common.set_volume_level(self.hass, 0.5, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.5 == state.attributes.get('volume_level')

        common.volume_down(self.hass, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.4 == state.attributes.get('volume_level')

        common.volume_up(self.hass, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.5 == state.attributes.get('volume_level')

        assert False is state.attributes.get('is_volume_muted')

        with pytest.raises(vol.Invalid):
            common.mute_volume(self.hass, None, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert False is state.attributes.get('is_volume_muted')

        common.mute_volume(self.hass, True, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert True is state.attributes.get('is_volume_muted')
Exemple #3
0
    def test_volume_services(self):
        """Test the volume service."""
        assert setup_component(
            self.hass, mp.DOMAIN,
            {'media_player': {'platform': 'demo'}})
        state = self.hass.states.get(entity_id)
        assert 1.0 == state.attributes.get('volume_level')

        with pytest.raises(vol.Invalid):
            common.set_volume_level(self.hass, None, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 1.0 == state.attributes.get('volume_level')

        common.set_volume_level(self.hass, 0.5, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.5 == state.attributes.get('volume_level')

        common.volume_down(self.hass, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.4 == state.attributes.get('volume_level')

        common.volume_up(self.hass, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert 0.5 == state.attributes.get('volume_level')

        assert False is state.attributes.get('is_volume_muted')

        common.mute_volume(self.hass, None, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert False is state.attributes.get('is_volume_muted')

        common.mute_volume(self.hass, True, entity_id)
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        assert True is state.attributes.get('is_volume_muted')