4dda842b16646b9f3863366a279d4dc65f262ece,tests/components/light/test_hue.py,TestSetup,test_update_lights_with_lights_and_groups,#TestSetup#Any#,192

Before Change


        Test the update_lights function with both lights and groups.
        self.setup_mocks_for_update_lights()
        self.mock_bridge.allow_hue_groups = True
        self.mock_lights = ["some", "light"]
        self.mock_groups = ["and", "groups"]

        with patch("homeassistant.components.light.hue.process_lights",
                   return_value=self.mock_lights) as mock_process_lights:
            with patch("homeassistant.components.light.hue.process_groups",
                       return_value=self.mock_groups) \
                    as mock_process_groups:
                hue_light.unthrottled_update_lights(
                    self.hass, self.mock_bridge, self.mock_add_devices)

                mock_process_lights.assert_called_once_with(
                    self.hass, self.mock_api, self.mock_bridge, mock.ANY)
                mock_process_groups.assert_called_once_with(
                    self.hass, self.mock_api, self.mock_bridge, mock.ANY)
                self.mock_add_devices.assert_called_once_with(
                    self.mock_lights)

    @MockDependency("phue")
    def test_update_lights_with_two_bridges(self, mock_phue):
        Test the update_lights function with two bridges.
        self.setup_mocks_for_update_lights()

After Change


        Test the update_lights function with both lights and groups.
        self.setup_mocks_for_update_lights()
        self.mock_bridge.allow_hue_groups = True
        mock_lights = [
            self.build_mock_light(self.mock_bridge, 42, "some"),
            self.build_mock_light(self.mock_bridge, 84, "light"),
        ]
        mock_groups = [
            self.build_mock_light(self.mock_bridge, 15, "and"),
            self.build_mock_light(self.mock_bridge, 72, "groups"),
        ]

        with patch(HUE_LIGHT_NS + "process_lights",
                   return_value=mock_lights) as mock_process_lights:
            with patch(HUE_LIGHT_NS + "process_groups",
                       return_value=mock_groups) as mock_process_groups:
                with patch.object(self.hass.helpers.dispatcher,
                                  "dispatcher_send") as dispatcher_send:
                    hue_light.unthrottled_update_lights(
                        self.hass, self.mock_bridge, self.mock_add_devices)

                    mock_process_lights.assert_called_once_with(
                        self.hass, self.mock_api, self.mock_bridge, mock.ANY)
                    mock_process_groups.assert_called_once_with(
                        self.hass, self.mock_api, self.mock_bridge, mock.ANY)
                    // note that mock_lights has been modified in place and
                    // now contains both lights and groups
                    self.mock_add_devices.assert_called_once_with(
                        mock_lights)
                    dispatcher_send.assert_not_called()

    @MockDependency("phue")
    def test_update_lights_with_two_bridges(self, mock_phue):
        Test the update_lights function with two bridges.
        self.setup_mocks_for_update_lights()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 22

Instances


Project Name: home-assistant/home-assistant
Commit Name: 4dda842b16646b9f3863366a279d4dc65f262ece
Time: 2018-01-09
Author: andrea.campi@gmail.com
File Name: tests/components/light/test_hue.py
Class Name: TestSetup
Method Name: test_update_lights_with_lights_and_groups


Project Name: home-assistant/home-assistant
Commit Name: 4dda842b16646b9f3863366a279d4dc65f262ece
Time: 2018-01-09
Author: andrea.campi@gmail.com
File Name: tests/components/light/test_hue.py
Class Name: TestSetup
Method Name: test_update_lights_no_groups


Project Name: home-assistant/home-assistant
Commit Name: 4dda842b16646b9f3863366a279d4dc65f262ece
Time: 2018-01-09
Author: andrea.campi@gmail.com
File Name: tests/components/light/test_hue.py
Class Name: TestSetup
Method Name: test_update_lights_with_lights_and_groups


Project Name: home-assistant/home-assistant
Commit Name: 4dda842b16646b9f3863366a279d4dc65f262ece
Time: 2018-01-09
Author: andrea.campi@gmail.com
File Name: tests/components/light/test_hue.py
Class Name: TestSetup
Method Name: test_update_lights_with_some_lights