mirror of
https://github.com/esphome/esphome.git
synced 2025-09-16 18:22:22 +01:00
cleanup
This commit is contained in:
@@ -599,10 +599,6 @@ async def test_archive_request_handler_post(
|
|||||||
test_config = config_dir / "test_archive.yaml"
|
test_config = config_dir / "test_archive.yaml"
|
||||||
test_config.write_text("esphome:\n name: test_archive\n")
|
test_config.write_text("esphome:\n name: test_archive\n")
|
||||||
|
|
||||||
# Mock storage_json to return None (no storage)
|
|
||||||
with patch("esphome.dashboard.web_server.StorageJSON.load") as mock_load:
|
|
||||||
mock_load.return_value = None
|
|
||||||
|
|
||||||
# Archive the configuration
|
# Archive the configuration
|
||||||
response = await dashboard.fetch(
|
response = await dashboard.fetch(
|
||||||
"/archive",
|
"/archive",
|
||||||
@@ -626,6 +622,7 @@ async def test_archive_handler_with_build_folder(
|
|||||||
mock_archive_storage_path: MagicMock,
|
mock_archive_storage_path: MagicMock,
|
||||||
mock_ext_storage_path: MagicMock,
|
mock_ext_storage_path: MagicMock,
|
||||||
mock_dashboard_settings: MagicMock,
|
mock_dashboard_settings: MagicMock,
|
||||||
|
mock_storage_json: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test ArchiveRequestHandler.post with storage_json and build folder."""
|
"""Test ArchiveRequestHandler.post with storage_json and build folder."""
|
||||||
@@ -654,11 +651,10 @@ async def test_archive_handler_with_build_folder(
|
|||||||
mock_archive_storage_path.return_value = str(archive_dir)
|
mock_archive_storage_path.return_value = str(archive_dir)
|
||||||
|
|
||||||
# Mock storage_json with device name and build_path
|
# Mock storage_json with device name and build_path
|
||||||
with patch("esphome.dashboard.web_server.StorageJSON.load") as mock_load:
|
|
||||||
mock_storage = MagicMock()
|
mock_storage = MagicMock()
|
||||||
mock_storage.name = "test_device"
|
mock_storage.name = "test_device"
|
||||||
mock_storage.build_path = str(build_folder)
|
mock_storage.build_path = str(build_folder)
|
||||||
mock_load.return_value = mock_storage
|
mock_storage_json.load.return_value = mock_storage
|
||||||
|
|
||||||
# Archive the configuration
|
# Archive the configuration
|
||||||
response = await dashboard.fetch(
|
response = await dashboard.fetch(
|
||||||
@@ -685,6 +681,7 @@ async def test_archive_handler_no_build_folder(
|
|||||||
mock_archive_storage_path: MagicMock,
|
mock_archive_storage_path: MagicMock,
|
||||||
mock_ext_storage_path: MagicMock,
|
mock_ext_storage_path: MagicMock,
|
||||||
mock_dashboard_settings: MagicMock,
|
mock_dashboard_settings: MagicMock,
|
||||||
|
mock_storage_json: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test ArchiveRequestHandler.post with storage_json but no build folder."""
|
"""Test ArchiveRequestHandler.post with storage_json but no build folder."""
|
||||||
@@ -707,11 +704,10 @@ async def test_archive_handler_no_build_folder(
|
|||||||
mock_archive_storage_path.return_value = str(archive_dir)
|
mock_archive_storage_path.return_value = str(archive_dir)
|
||||||
|
|
||||||
# Mock storage_json with device name but no build_path
|
# Mock storage_json with device name but no build_path
|
||||||
with patch("esphome.dashboard.web_server.StorageJSON.load") as mock_load:
|
|
||||||
mock_storage = MagicMock()
|
mock_storage = MagicMock()
|
||||||
mock_storage.name = "test_device"
|
mock_storage.name = "test_device"
|
||||||
mock_storage.build_path = None
|
mock_storage.build_path = None
|
||||||
mock_load.return_value = mock_storage
|
mock_storage_json.load.return_value = mock_storage
|
||||||
|
|
||||||
# Archive the configuration (should not fail even without build folder)
|
# Archive the configuration (should not fail even without build folder)
|
||||||
response = await dashboard.fetch(
|
response = await dashboard.fetch(
|
||||||
|
Reference in New Issue
Block a user