mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
		| @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch | ||||
|  | ||||
| import pytest | ||||
|  | ||||
| from esphome.components.packages import do_packages_pass | ||||
| from esphome.components.packages import CONFIG_SCHEMA, do_packages_pass | ||||
| from esphome.config import resolve_extend_remove | ||||
| from esphome.config_helpers import Extend, Remove | ||||
| import esphome.config_validation as cv | ||||
| @@ -94,6 +94,50 @@ def test_package_invalid_dict(basic_esphome, basic_wifi): | ||||
|         packages_pass(config) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize( | ||||
|     "package", | ||||
|     [ | ||||
|         {"package1": "github://esphome/non-existant-repo/file1.yml@main"}, | ||||
|         {"package2": "github://esphome/non-existant-repo/file1.yml"}, | ||||
|         {"package3": "github://esphome/non-existant-repo/other-folder/file1.yml"}, | ||||
|         [ | ||||
|             "github://esphome/non-existant-repo/file1.yml@main", | ||||
|             "github://esphome/non-existant-repo/file1.yml", | ||||
|             "github://esphome/non-existant-repo/other-folder/file1.yml", | ||||
|         ], | ||||
|     ], | ||||
| ) | ||||
| def test_package_shorthand(package): | ||||
|     CONFIG_SCHEMA(package) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize( | ||||
|     "package", | ||||
|     [ | ||||
|         # not github | ||||
|         {"package1": "someplace://esphome/non-existant-repo/file1.yml@main"}, | ||||
|         # missing repo | ||||
|         {"package2": "github://esphome/file1.yml"}, | ||||
|         # missing file | ||||
|         {"package3": "github://esphome/non-existant-repo/@main"}, | ||||
|         {"a": "invalid string, not shorthand"}, | ||||
|         "some string", | ||||
|         3, | ||||
|         False, | ||||
|         {"a": 8}, | ||||
|         ["someplace://esphome/non-existant-repo/file1.yml@main"], | ||||
|         ["github://esphome/file1.yml"], | ||||
|         ["github://esphome/non-existant-repo/@main"], | ||||
|         ["some string"], | ||||
|         [True], | ||||
|         [3], | ||||
|     ], | ||||
| ) | ||||
| def test_package_invalid(package): | ||||
|     with pytest.raises(cv.Invalid): | ||||
|         CONFIG_SCHEMA(package) | ||||
|  | ||||
|  | ||||
| def test_package_include(basic_wifi, basic_esphome): | ||||
|     """ | ||||
|     Tests the simple case where an independent config present in a package is added to the top-level config as is. | ||||
|   | ||||
| @@ -4,51 +4,6 @@ wifi: | ||||
|   ssid: MySSID | ||||
|   password: password1 | ||||
|  | ||||
| esphome: | ||||
|   on_boot: | ||||
|     then: | ||||
|       - http_request.get: | ||||
|           url: https://esphome.io | ||||
|           request_headers: | ||||
|             Content-Type: application/json | ||||
|           collect_headers: | ||||
|             - age | ||||
|           on_error: | ||||
|             logger.log: "Request failed" | ||||
|           on_response: | ||||
|             then: | ||||
|               - logger.log: | ||||
|                   format: "Response status: %d, Duration: %lu ms, age: %s" | ||||
|                   args: | ||||
|                     - response->status_code | ||||
|                     - (long) response->duration_ms | ||||
|                     - response->get_response_header("age").c_str() | ||||
|       - http_request.post: | ||||
|           url: https://esphome.io | ||||
|           request_headers: | ||||
|             Content-Type: application/json | ||||
|           json: | ||||
|             key: value | ||||
|       - http_request.send: | ||||
|           method: PUT | ||||
|           url: https://esphome.io | ||||
|           request_headers: | ||||
|             Content-Type: application/json | ||||
|           body: "Some data" | ||||
|  | ||||
| http_request: | ||||
|   useragent: esphome/tagreader | ||||
|   timeout: 10s | ||||
|   verify_ssl: ${verify_ssl} | ||||
|  | ||||
| script: | ||||
|   - id: does_not_compile | ||||
|     parameters: | ||||
|       api_url: string | ||||
|     then: | ||||
|       - http_request.get: | ||||
|           url: "http://google.com" | ||||
|  | ||||
| ota: | ||||
|   - platform: http_request | ||||
|     id: http_request_ota | ||||
|   | ||||
| @@ -31,6 +31,20 @@ esphome: | ||||
|           request_headers: | ||||
|             Content-Type: application/json | ||||
|           body: "Some data" | ||||
|       - http_request.post: | ||||
|           url: https://esphome.io | ||||
|           request_headers: | ||||
|             Content-Type: application/json | ||||
|           json: | ||||
|             key: value | ||||
|           capture_response: true | ||||
|           on_response: | ||||
|             then: | ||||
|               - logger.log: | ||||
|                   format: "Captured response status: %d, Body: %s" | ||||
|                   args: | ||||
|                     - response->status_code | ||||
|                     - body.c_str() | ||||
|  | ||||
| http_request: | ||||
|   useragent: esphome/tagreader | ||||
|   | ||||
		Reference in New Issue
	
	Block a user