mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Wake-on-LAN button (#3030)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: William Charlton <will.charlton1@icloud.com>
This commit is contained in:
		
							
								
								
									
										46
									
								
								tests/component_tests/button/test_button.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								tests/component_tests/button/test_button.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| """Tests for the button component""" | ||||
|  | ||||
|  | ||||
| def test_button_is_setup(generate_main): | ||||
|     """ | ||||
|     When the button is set in the yaml file if should be registered in main | ||||
|     """ | ||||
|     # Given | ||||
|  | ||||
|     # When | ||||
|     main_cpp = generate_main("tests/component_tests/button/test_button.yaml") | ||||
|  | ||||
|     # Then | ||||
|     assert "new wake_on_lan::WakeOnLanButton();" in main_cpp | ||||
|     assert "App.register_button" in main_cpp | ||||
|     assert "App.register_component" in main_cpp | ||||
|  | ||||
|  | ||||
| def test_button_sets_mandatory_fields(generate_main): | ||||
|     """ | ||||
|     When the mandatory fields are set in the yaml, they should be set in main | ||||
|     """ | ||||
|     # Given | ||||
|  | ||||
|     # When | ||||
|     main_cpp = generate_main("tests/component_tests/button/test_button.yaml") | ||||
|  | ||||
|     # Then | ||||
|     assert 'wol_1->set_name("wol_test_1");' in main_cpp | ||||
|     assert "wol_2->set_macaddr(18, 52, 86, 120, 144, 171);" in main_cpp | ||||
|  | ||||
|  | ||||
| def test_button_config_value_internal_set(generate_main): | ||||
|     """ | ||||
|     Test that the "internal" config value is correctly set | ||||
|     """ | ||||
|     # Given | ||||
|  | ||||
|     # When | ||||
|     main_cpp = generate_main( | ||||
|         "tests/component_tests/button/test_button.yaml" | ||||
|     ) | ||||
|  | ||||
|     # Then | ||||
|     assert "wol_1->set_internal(true);" in main_cpp | ||||
|     assert "wol_2->set_internal(false);" in main_cpp | ||||
							
								
								
									
										21
									
								
								tests/component_tests/button/test_button.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								tests/component_tests/button/test_button.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| esphome: | ||||
|   name: test | ||||
|   platform: ESP8266 | ||||
|   board: d1_mini_lite | ||||
|  | ||||
| wifi: | ||||
|   ssid: SomeNetwork | ||||
|   password: SomePassword | ||||
|  | ||||
| button: | ||||
|   - platform: wake_on_lan | ||||
|     target_mac_address: 12:34:56:78:90:ab | ||||
|     name: wol_test_1 | ||||
|     id: wol_1 | ||||
|     internal: true | ||||
|   - platform: wake_on_lan | ||||
|     target_mac_address: 12:34:56:78:90:ab | ||||
|     name: wol_test_2 | ||||
|     id: wol_2 | ||||
|     internal: false | ||||
|    | ||||
		Reference in New Issue
	
	Block a user