mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 06:33:51 +00:00 
			
		
		
		
	Disallow _ in node name (#1632)
This commit is contained in:
		| @@ -27,7 +27,7 @@ def test_alphanumeric__invalid(value): | ||||
|         config_validation.alphanumeric(value) | ||||
|  | ||||
|  | ||||
| @given(value=text(alphabet=string.ascii_lowercase + string.digits + "_-")) | ||||
| @given(value=text(alphabet=string.ascii_lowercase + string.digits + "-_")) | ||||
| def test_valid_name__valid(value): | ||||
|     actual = config_validation.valid_name(value) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|     ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user