Beispiel #1
0
    def test_all_entities_can_be_loaded_over_json(self, mock_sun_setup):
        """ Test if you can hide the demo card. """
        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': 1}})

        try:
            json.dumps(self.hass.states.all(), cls=JSONEncoder)
        except Exception:
            self.fail('Unable to convert all demo entities to JSON. '
                      'Wrong data in state machine!')
Beispiel #2
0
    def test_all_entities_can_be_loaded_over_json(self, mock_sun_setup):
        """Test if you can hide the demo card."""
        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': 1}})

        try:
            json.dumps(self.hass.states.all(), cls=JSONEncoder)
        except Exception:
            self.fail('Unable to convert all demo entities to JSON. '
                      'Wrong data in state machine!')
    def test_hiding_demo_state(self):
        """ Test if you can hide the demo card. """
        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': '1'}})

        self.assertIsNone(self.hass.states.get('a.Demo_Mode'))

        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': '0'}})

        self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))
    def test_hiding_demo_state(self):
        """ Test if you can hide the demo card. """
        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': '1'}})

        self.assertIsNone(self.hass.states.get('a.Demo_Mode'))

        demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': '0'}})

        self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))
    def test_services(self):
        """ Test the demo services. """
        # Test turning on and off different types
        demo.setup(self.hass, {})

        for domain in ('light', 'switch'):
            # Focus on 1 entity
            entity_id = self.hass.states.entity_ids(domain)[0]

            self.hass.services.call(
                domain, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id})

            self.hass.pool.block_till_done()

            self.assertEqual(STATE_ON, self.hass.states.get(entity_id).state)

            self.hass.services.call(
                domain, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id})

            self.hass.pool.block_till_done()

            self.assertEqual(STATE_OFF, self.hass.states.get(entity_id).state)

            # Act on all
            self.hass.services.call(domain, SERVICE_TURN_ON)

            self.hass.pool.block_till_done()

            for entity_id in self.hass.states.entity_ids(domain):
                self.assertEqual(
                    STATE_ON, self.hass.states.get(entity_id).state)

            self.hass.services.call(domain, SERVICE_TURN_OFF)

            self.hass.pool.block_till_done()

            for entity_id in self.hass.states.entity_ids(domain):
                self.assertEqual(
                    STATE_OFF, self.hass.states.get(entity_id).state)
    def test_services(self):
        """ Test the demo services. """
        # Test turning on and off different types
        demo.setup(self.hass, {})

        for domain in ('light', 'switch'):
            # Focus on 1 entity
            entity_id = self.hass.states.entity_ids(domain)[0]

            self.hass.services.call(
                domain, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id})

            self.hass._pool.block_till_done()

            self.assertEqual(STATE_ON, self.hass.states.get(entity_id).state)

            self.hass.services.call(
                domain, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id})

            self.hass._pool.block_till_done()

            self.assertEqual(STATE_OFF, self.hass.states.get(entity_id).state)

            # Act on all
            self.hass.services.call(domain, SERVICE_TURN_ON)

            self.hass._pool.block_till_done()

            for entity_id in self.hass.states.entity_ids(domain):
                self.assertEqual(
                    STATE_ON, self.hass.states.get(entity_id).state)

            self.hass.services.call(domain, SERVICE_TURN_OFF)

            self.hass._pool.block_till_done()

            for entity_id in self.hass.states.entity_ids(domain):
                self.assertEqual(
                    STATE_OFF, self.hass.states.get(entity_id).state)
Beispiel #7
0
    def test_if_demo_state_shows_by_default(self, mock_sun_setup):
        """ Test if demo state shows if we give no configuration. """
        demo.setup(self.hass, {demo.DOMAIN: {}})

        self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))
Beispiel #8
0
    def test_if_demo_state_shows_by_default(self, mock_sun_setup):
        """Test if demo state shows if we give no configuration."""
        demo.setup(self.hass, {demo.DOMAIN: {}})

        self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))