'Test the provided services.'

def test_services(self):

    platform = loader.get_component('light.test')
    platform.init()
    self.assertTrue(setup_component(self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}}))
    (dev1, dev2, dev3) = platform.DEVICES
    self.assertTrue(light.is_on(self.hass, dev1.entity_id))
    self.assertFalse(light.is_on(self.hass, dev2.entity_id))
    self.assertFalse(light.is_on(self.hass, dev3.entity_id))
    light.turn_off(self.hass, entity_id=dev1.entity_id)
    light.turn_on(self.hass, entity_id=dev2.entity_id)
    self.hass.block_till_done()
    self.assertFalse(light.is_on(self.hass, dev1.entity_id))
    self.assertTrue(light.is_on(self.hass, dev2.entity_id))
    light.turn_on(self.hass)
    self.hass.block_till_done()
    self.assertTrue(light.is_on(self.hass, dev1.entity_id))
    self.assertTrue(light.is_on(self.hass, dev2.entity_id))
    self.assertTrue(light.is_on(self.hass, dev3.entity_id))
    light.turn_off(self.hass)
    self.hass.block_till_done()
    self.assertFalse(light.is_on(self.hass, dev1.entity_id))
    self.assertFalse(light.is_on(self.hass, dev2.entity_id))
    self.assertFalse(light.is_on(self.hass, dev3.entity_id))
    light.toggle(self.hass)
    self.hass.block_till_done()
    self.assertTrue(light.is_on(self.hass, dev1.entity_id))
    self.assertTrue(light.is_on(self.hass, dev2.entity_id))
    self.assertTrue(light.is_on(self.hass, dev3.entity_id))
    light.toggle(self.hass)
    self.hass.block_till_done()
    self.assertFalse(light.is_on(self.hass, dev1.entity_id))
    self.assertFalse(light.is_on(self.hass, dev2.entity_id))
    self.assertFalse(light.is_on(self.hass, dev3.entity_id))
    light.turn_on(self.hass, dev1.entity_id, transition=10, brightness=20, color_name='blue')
    light.turn_on(self.hass, dev2.entity_id, rgb_color=(255, 255, 255), white_value=255)
    light.turn_on(self.hass, dev3.entity_id, xy_color=(0.4, 0.6))
    self.hass.block_till_done()
    (_, data) = dev1.last_call('turn_on')
    self.assertEqual({light.ATTR_TRANSITION: 10, light.ATTR_BRIGHTNESS: 20, light.ATTR_RGB_COLOR: (0, 0, 255)}, data)
    (_, data) = dev2.last_call('turn_on')
    self.assertEqual({light.ATTR_RGB_COLOR: (255, 255, 255), light.ATTR_WHITE_VALUE: 255}, data)
    (_, data) = dev3.last_call('turn_on')
    self.assertEqual({light.ATTR_XY_COLOR: (0.4, 0.6)}, data)
    (prof_name, prof_x, prof_y, prof_bri) = ('relax', 0.5119, 0.4147, 144)
    light.turn_on(self.hass, dev1.entity_id, profile=prof_name)
    light.turn_on(self.hass, dev2.entity_id, profile=prof_name, brightness=100)
    self.hass.block_till_done()
    (_, data) = dev1.last_call('turn_on')
    self.assertEqual({light.ATTR_BRIGHTNESS: prof_bri, light.ATTR_XY_COLOR: (prof_x, prof_y)}, data)
    (_, data) = dev2.last_call('turn_on')
    self.assertEqual({light.ATTR_BRIGHTNESS: 100, light.ATTR_XY_COLOR: (0.5119, 0.4147)}, data)
    light.turn_on(self.hass)
    light.turn_on(self.hass, dev1.entity_id, profile='nonexisting')
    light.turn_on(self.hass, dev2.entity_id, xy_color=['bla-di-bla', 5])
    light.turn_on(self.hass, dev3.entity_id, rgb_color=[255, None, 2])
    self.hass.block_till_done()
    (_, data) = dev1.last_call('turn_on')
    self.assertEqual({}, data)
    (_, data) = dev2.last_call('turn_on')
    self.assertEqual({}, data)
    (_, data) = dev3.last_call('turn_on')
    self.assertEqual({}, data)
    light.turn_on(self.hass, dev1.entity_id, profile=prof_name, brightness='bright')
    light.turn_on(self.hass, dev1.entity_id, rgb_color='yellowish')
    light.turn_on(self.hass, dev2.entity_id, white_value='high')
    self.hass.block_till_done()
    (_, data) = dev1.last_call('turn_on')
    self.assertEqual({}, data)
    (_, data) = dev2.last_call('turn_on')
    self.assertEqual({}, data)
