Exemplo n.º 1
0
 def test_should_send_correct_color_temperature_values_to_wink_api(self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True, color_kelvin=arbitrary_kelvin_color)
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('color_temperature', sent_data['desired_state'].get('color_model'))
     self.assertEquals(arbitrary_kelvin_color, sent_data['desired_state'].get('color_temperature'))
Exemplo n.º 2
0
 def test_should_only_send_color_xy_if_both_color_xy_and_color_temperature_are_given(self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True, color_kelvin=arbitrary_kelvin_color, color_xy=[0, 1])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('color_temperature', sent_data['desired_state'].get('color_model'))
     self.assertNotIn('color_x', sent_data['desired_state'])
     self.assertNotIn('color_y', sent_data['desired_state'])
Exemplo n.º 3
0
 def test_should_send_correct_color_xy_values_to_wink_api(self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     color_x = 0.75
     color_y = 0.25
     bulb.set_state(True, color_xy=[color_x, color_y])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals(color_x, sent_data.get('desired_state', {}).get('color_x'))
     self.assertEquals(color_y, sent_data.get('desired_state', {}).get('color_y'))
     self.assertEquals('xy', sent_data['desired_state'].get('color_model'))
Exemplo n.º 4
0
 def test_should_send_correct_color_temperature_values_to_wink_api(
         self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True, color_kelvin=arbitrary_kelvin_color)
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('color_temperature',
                       sent_data['desired_state'].get('color_model'))
     self.assertEquals(arbitrary_kelvin_color,
                       sent_data['desired_state'].get('color_temperature'))
Exemplo n.º 5
0
 def test_should_send_correct_color_xy_values_to_wink_api(self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     color_x = 0.75
     color_y = 0.25
     bulb.set_state(True, color_xy=[color_x, color_y])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals(color_x,
                       sent_data.get('desired_state', {}).get('color_x'))
     self.assertEquals(color_y,
                       sent_data.get('desired_state', {}).get('color_y'))
     self.assertEquals('xy', sent_data['desired_state'].get('color_model'))
Exemplo n.º 6
0
 def test_should_only_send_color_xy_if_both_color_xy_and_color_temperature_are_given(
         self, put_mock):
     bulb = WinkBulb({}, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True,
                    color_kelvin=arbitrary_kelvin_color,
                    color_xy=[0, 1])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('color_temperature',
                       sent_data['desired_state'].get('color_model'))
     self.assertNotIn('color_x', sent_data['desired_state'])
     self.assertNotIn('color_y', sent_data['desired_state'])
Exemplo n.º 7
0
 def test_should_send_color_temperature_to_api_if_color_temp_is_provided_and_bulb_only_supports_temperature(self):
     bulb = WinkBulb({
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["color_temperature"]}]
         }
     }, self.api_interface)
     color_kelvin = 4000
     bulb.set_state(True, color_kelvin=color_kelvin)
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(color_kelvin, sent_desired_state.get('color_temperature'))
Exemplo n.º 8
0
 def test_should_only_send_color_hsb_if_both_color_hsb_and_color_temperature_are_given(self, put_mock):
     bulb = WinkBulb({
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["hsb"]}]
         }
     }, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True, color_kelvin=arbitrary_kelvin_color, color_hue_saturation=[0, 1])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))
     self.assertNotIn('color_temperature', sent_data['desired_state'])
Exemplo n.º 9
0
 def test_should_send_current_hue_and_saturation_to_api_if_hue_and_sat_are_provided_and_bulb_only_supports_hue_sat(self):
     bulb = WinkBulb({
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["hsb"]}]
         }
     }, self.api_interface)
     hue = 0.2
     saturation = 0.3
     bulb.set_state(True, color_hue_saturation=[hue, saturation])
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(hue, sent_desired_state.get('hue'))
     self.assertEquals(saturation, sent_desired_state.get('saturation'))
Exemplo n.º 10
0
 def test_should_send_correct_color_hsb_values_to_wink_api(self, put_mock):
     bulb = WinkBulb({
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["hsb"]}]
         }
     }, self.api_interface)
     hue = 0.75
     saturation = 0.25
     bulb.set_state(True, color_hue_saturation=[hue, saturation])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals(hue, sent_data.get('desired_state', {}).get('hue'))
     self.assertEquals(saturation, sent_data.get('desired_state', {}).get('saturation'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))
Exemplo n.º 11
0
 def test_should_send_current_brightness_to_api_if_only_color_temperature_is_provided_and_bulb_only_supports_temperature(self):
     original_brightness = 0.5
     bulb = WinkBulb({
         'last_reading': {
             'desired_brightness': original_brightness
         },
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["color_temperature"]}]
         }
     }, self.api_interface)
     bulb.set_state(True, color_kelvin=4000)
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(original_brightness, sent_desired_state.get('brightness'))
Exemplo n.º 12
0
 def test_should_send_original_brightness_when_only_xy_color_given_and_only_hue_saturation_supported(self):
     original_brightness = 0.5
     bulb = WinkBulb({
         'last_reading': {
             'desired_brightness': original_brightness
         },
         'capabilities': {
             'fields': [{'field': 'color_model',
                        'choices':["hsb"]}]
         }
     }, self.api_interface)
     bulb.set_state(True, color_xy=[0.5, 0.5])
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(original_brightness, sent_desired_state.get('brightness'))
Exemplo n.º 13
0
 def test_should_send_color_temperature_to_api_if_color_temp_is_provided_and_bulb_only_supports_temperature(
         self):
     bulb = WinkBulb(
         {
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["color_temperature"]
                 }]
             }
         }, self.api_interface)
     color_kelvin = 4000
     bulb.set_state(True, color_kelvin=color_kelvin)
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(color_kelvin,
                       sent_desired_state.get('color_temperature'))
Exemplo n.º 14
0
 def test_should_send_current_hue_and_saturation_to_api_if_hue_and_sat_are_provided_and_bulb_only_supports_hue_sat(
         self):
     bulb = WinkBulb(
         {
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["hsb"]
                 }]
             }
         }, self.api_interface)
     hue = 0.2
     saturation = 0.3
     bulb.set_state(True, color_hue_saturation=[hue, saturation])
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(hue, sent_desired_state.get('hue'))
     self.assertEquals(saturation, sent_desired_state.get('saturation'))
Exemplo n.º 15
0
 def test_should_send_correct_color_hsb_values_to_wink_api(self, put_mock):
     bulb = WinkBulb(
         {
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["hsb"]
                 }]
             }
         }, self.api_interface)
     hue = 0.75
     saturation = 0.25
     bulb.set_state(True, color_hue_saturation=[hue, saturation])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals(hue, sent_data.get('desired_state', {}).get('hue'))
     self.assertEquals(saturation,
                       sent_data.get('desired_state', {}).get('saturation'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))
Exemplo n.º 16
0
 def test_should_only_send_color_hsb_if_both_color_hsb_and_color_temperature_are_given(
         self, put_mock):
     bulb = WinkBulb(
         {
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["hsb"]
                 }]
             }
         }, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True,
                    color_kelvin=arbitrary_kelvin_color,
                    color_hue_saturation=[0, 1])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))
     self.assertNotIn('color_temperature', sent_data['desired_state'])
Exemplo n.º 17
0
 def test_should_only_send_color_hsb_if_both_color_hsb_and_color_temperature_are_given(self, put_mock):
     bulb = WinkBulb({
         "capabilities": {
             "fields": [
                 {
                     "field": "hue"
                 },
                 {
                     "field": "saturation"
                 }
             ],
             "color_changeable": True
         }
     }, self.api_interface)
     arbitrary_kelvin_color = 4950
     bulb.set_state(True, color_kelvin=arbitrary_kelvin_color, color_hue_saturation=[0, 1])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))
     self.assertNotIn('color_temperature', sent_data['desired_state'])
Exemplo n.º 18
0
 def test_should_send_original_brightness_when_only_xy_color_given_and_only_hue_saturation_supported(
         self):
     original_brightness = 0.5
     bulb = WinkBulb(
         {
             'last_reading': {
                 'desired_brightness': original_brightness
             },
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["hsb"]
                 }]
             }
         }, self.api_interface)
     bulb.set_state(True, color_xy=[0.5, 0.5])
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(original_brightness,
                       sent_desired_state.get('brightness'))
Exemplo n.º 19
0
 def test_should_send_current_brightness_to_api_if_only_color_temperature_is_provided_and_bulb_only_supports_hue_sat(
         self):
     original_brightness = 0.5
     bulb = WinkBulb(
         {
             'last_reading': {
                 'desired_brightness': original_brightness
             },
             'capabilities': {
                 'fields': [{
                     'field': 'color_model',
                     'choices': ["hsb"]
                 }]
             }
         }, self.api_interface)
     bulb.set_state(True, color_kelvin=4000)
     set_state_mock = self.api_interface.set_device_state
     sent_desired_state = set_state_mock.call_args[0][1]['desired_state']
     self.assertEquals(original_brightness,
                       sent_desired_state.get('brightness'))
Exemplo n.º 20
0
 def test_should_send_correct_color_hsb_values_to_wink_api(self, put_mock):
     bulb = WinkBulb({
         "capabilities": {
             "fields": [
                 {
                     "field": "hue"
                 },
                 {
                     "field": "saturation"
                 }
             ],
             "color_changeable": True
         }
     }, self.api_interface)
     hue = 0.75
     saturation = 0.25
     bulb.set_state(True, color_hue_saturation=[hue, saturation])
     sent_data = json.loads(put_mock.call_args[1].get('data'))
     self.assertEquals(hue, sent_data.get('desired_state', {}).get('hue'))
     self.assertEquals(saturation, sent_data.get('desired_state', {}).get('saturation'))
     self.assertEquals('hsb', sent_data['desired_state'].get('color_model'))