fe8dec27a38cfeeb00129a555e1a4e850b1e4251,tests/components/emulated_hue/test_init.py,,test_config_google_home_entity_id_to_number_altered,#,43

Before Change


        "type": "google_home"
    })

    mop = mock_open(read_data=json.dumps({"21": "light.test2"}))
    handle = mop()

    with patch("homeassistant.util.json.open", mop, create=True):
        with patch("homeassistant.util.json.os.open", return_value=0):
            with patch("homeassistant.util.json.os.replace"):
                number = conf.entity_id_to_number("light.test")
                assert number == "22"
                assert handle.write.call_count == 1
                assert json.loads(handle.write.mock_calls[0][1][0]) == {
                    "21": "light.test2",
                    "22": "light.test",
                }

                number = conf.entity_id_to_number("light.test")
                assert number == "22"
                assert handle.write.call_count == 1

                number = conf.entity_id_to_number("light.test2")
                assert number == "21"
                assert handle.write.call_count == 1

                entity_id = conf.number_to_entity_id("21")
                assert entity_id == "light.test2"


def test_config_google_home_entity_id_to_number_empty():
    Test config adheres to the type.
    mock_hass = Mock()
    mock_hass.config.path = MagicMock("path", return_value="test_path")

After Change


        "type": "google_home"
    })

    with patch("homeassistant.components.emulated_hue.load_json",
               return_value={"21": "light.test2"}) as json_loader:
        with patch("homeassistant.components.emulated_hue"
                   ".save_json") as json_saver:
            number = conf.entity_id_to_number("light.test")
            assert number == "22"
            assert json_saver.call_count == 1
            assert json_loader.call_count == 1

            assert json_saver.mock_calls[0][1][1] == {
                "21": "light.test2",
                "22": "light.test",
            }

            number = conf.entity_id_to_number("light.test")
            assert number == "22"
            assert json_saver.call_count == 1

            number = conf.entity_id_to_number("light.test2")
            assert number == "21"
            assert json_saver.call_count == 1

            entity_id = conf.number_to_entity_id("21")
            assert entity_id == "light.test2"


def test_config_google_home_entity_id_to_number_empty():
    Test config adheres to the type.
    mock_hass = Mock()
    mock_hass.config.path = MagicMock("path", return_value="test_path")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 13

Instances


Project Name: home-assistant/home-assistant
Commit Name: fe8dec27a38cfeeb00129a555e1a4e850b1e4251
Time: 2018-10-23
Author: nicko@nicko.org
File Name: tests/components/emulated_hue/test_init.py
Class Name:
Method Name: test_config_google_home_entity_id_to_number_altered


Project Name: home-assistant/home-assistant
Commit Name: 50f0eac7f37c2339a56f77e12da443edae3bdf9c
Time: 2018-10-23
Author: nicko@nicko.org
File Name: tests/components/emulated_hue/test_init.py
Class Name:
Method Name: test_config_google_home_entity_id_to_number


Project Name: home-assistant/home-assistant
Commit Name: 50f0eac7f37c2339a56f77e12da443edae3bdf9c
Time: 2018-10-23
Author: nicko@nicko.org
File Name: tests/components/emulated_hue/test_init.py
Class Name:
Method Name: test_config_google_home_entity_id_to_number_altered


Project Name: home-assistant/home-assistant
Commit Name: fe8dec27a38cfeeb00129a555e1a4e850b1e4251
Time: 2018-10-23
Author: nicko@nicko.org
File Name: tests/components/emulated_hue/test_init.py
Class Name:
Method Name: test_config_google_home_entity_id_to_number