mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	wip
This commit is contained in:
		
							
								
								
									
										21
									
								
								tests/dashboard/conftest.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								tests/dashboard/conftest.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| """Common fixtures for dashboard tests.""" | ||||
|  | ||||
| from __future__ import annotations | ||||
|  | ||||
| from unittest.mock import Mock | ||||
|  | ||||
| import pytest | ||||
|  | ||||
| from esphome.dashboard.core import ESPHomeDashboard | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def mock_dashboard() -> Mock: | ||||
|     """Create a mock dashboard.""" | ||||
|     dashboard = Mock(spec=ESPHomeDashboard) | ||||
|     dashboard.entries = Mock() | ||||
|     dashboard.entries.async_all.return_value = [] | ||||
|     dashboard.stop_event = Mock() | ||||
|     dashboard.stop_event.is_set.return_value = True | ||||
|     dashboard.ping_request = Mock() | ||||
|     return dashboard | ||||
| @@ -8,22 +8,9 @@ import pytest | ||||
| import pytest_asyncio | ||||
| from zeroconf import AddressResolver, IPVersion | ||||
|  | ||||
| from esphome.dashboard.core import ESPHomeDashboard | ||||
| from esphome.dashboard.status.mdns import MDNSStatus | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def mock_dashboard() -> Mock: | ||||
|     """Create a mock dashboard.""" | ||||
|     dashboard = Mock(spec=ESPHomeDashboard) | ||||
|     dashboard.entries = Mock() | ||||
|     dashboard.entries.async_all.return_value = [] | ||||
|     dashboard.stop_event = Mock() | ||||
|     dashboard.stop_event.is_set.return_value = True | ||||
|     dashboard.ping_request = Mock() | ||||
|     return dashboard | ||||
|  | ||||
|  | ||||
| @pytest_asyncio.fixture | ||||
| async def mdns_status(mock_dashboard: Mock) -> MDNSStatus: | ||||
|     """Create an MDNSStatus instance in async context.""" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user