mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	fix tests
This commit is contained in:
		| @@ -59,12 +59,22 @@ def mock_subprocess_run() -> Generator[Mock, None, None]: | ||||
|         yield mock | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def mock_changed_files() -> Generator[Mock, None, None]: | ||||
|     """Mock changed_files for memory impact detection.""" | ||||
|     with patch.object(determine_jobs, "changed_files") as mock: | ||||
|         # Default to empty list | ||||
|         mock.return_value = [] | ||||
|         yield mock | ||||
|  | ||||
|  | ||||
| def test_main_all_tests_should_run( | ||||
|     mock_should_run_integration_tests: Mock, | ||||
|     mock_should_run_clang_tidy: Mock, | ||||
|     mock_should_run_clang_format: Mock, | ||||
|     mock_should_run_python_linters: Mock, | ||||
|     mock_subprocess_run: Mock, | ||||
|     mock_changed_files: Mock, | ||||
|     capsys: pytest.CaptureFixture[str], | ||||
| ) -> None: | ||||
|     """Test when all tests should run.""" | ||||
| @@ -98,6 +108,9 @@ def test_main_all_tests_should_run( | ||||
|     assert output["component_test_count"] == len( | ||||
|         output["changed_components_with_tests"] | ||||
|     ) | ||||
|     # memory_impact should be present | ||||
|     assert "memory_impact" in output | ||||
|     assert output["memory_impact"]["should_run"] == "false"  # No files changed | ||||
|  | ||||
|  | ||||
| def test_main_no_tests_should_run( | ||||
| @@ -106,6 +119,7 @@ def test_main_no_tests_should_run( | ||||
|     mock_should_run_clang_format: Mock, | ||||
|     mock_should_run_python_linters: Mock, | ||||
|     mock_subprocess_run: Mock, | ||||
|     mock_changed_files: Mock, | ||||
|     capsys: pytest.CaptureFixture[str], | ||||
| ) -> None: | ||||
|     """Test when no tests should run.""" | ||||
| @@ -134,6 +148,9 @@ def test_main_no_tests_should_run( | ||||
|     assert output["changed_components"] == [] | ||||
|     assert output["changed_components_with_tests"] == [] | ||||
|     assert output["component_test_count"] == 0 | ||||
|     # memory_impact should be present | ||||
|     assert "memory_impact" in output | ||||
|     assert output["memory_impact"]["should_run"] == "false" | ||||
|  | ||||
|  | ||||
| def test_main_list_components_fails( | ||||
| @@ -167,6 +184,7 @@ def test_main_with_branch_argument( | ||||
|     mock_should_run_clang_format: Mock, | ||||
|     mock_should_run_python_linters: Mock, | ||||
|     mock_subprocess_run: Mock, | ||||
|     mock_changed_files: Mock, | ||||
|     capsys: pytest.CaptureFixture[str], | ||||
| ) -> None: | ||||
|     """Test with branch argument.""" | ||||
| @@ -212,6 +230,9 @@ def test_main_with_branch_argument( | ||||
|     assert output["component_test_count"] == len( | ||||
|         output["changed_components_with_tests"] | ||||
|     ) | ||||
|     # memory_impact should be present | ||||
|     assert "memory_impact" in output | ||||
|     assert output["memory_impact"]["should_run"] == "false" | ||||
|  | ||||
|  | ||||
| def test_should_run_integration_tests( | ||||
| @@ -399,6 +420,7 @@ def test_main_filters_components_without_tests( | ||||
|     mock_should_run_clang_format: Mock, | ||||
|     mock_should_run_python_linters: Mock, | ||||
|     mock_subprocess_run: Mock, | ||||
|     mock_changed_files: Mock, | ||||
|     capsys: pytest.CaptureFixture[str], | ||||
|     tmp_path: Path, | ||||
| ) -> None: | ||||
| @@ -448,3 +470,6 @@ def test_main_filters_components_without_tests( | ||||
|     assert set(output["changed_components_with_tests"]) == {"wifi", "sensor"} | ||||
|     # component_test_count should be based on components with tests | ||||
|     assert output["component_test_count"] == 2 | ||||
|     # memory_impact should be present | ||||
|     assert "memory_impact" in output | ||||
|     assert output["memory_impact"]["should_run"] == "false" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user