1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

Disallow _ in node name (#1632)

This commit is contained in:
Peter Kuehne
2021-04-08 13:26:01 +01:00
committed by GitHub
parent 2e50e1f506
commit eaf9735eda
6 changed files with 18 additions and 12 deletions

View File

@@ -9,7 +9,7 @@ from mock import MagicMock
@pytest.fixture
def default_config():
return {
"name": "test_name",
"name": "test-name",
"platform": "test_platform",
"board": "test_board",
"ssid": "test_ssid",
@@ -21,7 +21,7 @@ def default_config():
@pytest.fixture
def wizard_answers():
return [
"test_node", # Name of the node
"test-node", # Name of the node
"ESP8266", # platform
"nodemcuv2", # board
"SSID", # ssid
@@ -305,13 +305,14 @@ def test_wizard_offers_better_node_name(tmpdir, monkeypatch, wizard_answers):
"""
When the node name does not conform, a better alternative is offered
* Removes special chars
* Replaces spaces with underscores
* Replaces spaces with hyphens
* Replaces underscores with hyphens
* Converts all uppercase letters to lowercase
"""
# Given
wizard_answers[0] = "Küche #2"
expected_name = "kuche_2"
wizard_answers[0] = "Küche_Unten #2"
expected_name = "kuche-unten-2"
monkeypatch.setattr(
wz, "default_input", MagicMock(side_effect=lambda _, default: default)
)