1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00
This commit is contained in:
J. Nick Koston
2025-09-16 11:57:10 -05:00
parent 586f24e02d
commit c39320c515
5 changed files with 212 additions and 261 deletions

View File

@@ -732,96 +732,3 @@ def test_remote_packages_with_files_and_vars(
actual = do_packages_pass(config)
assert actual == expected
@patch("esphome.git.clone_or_update")
@patch("esphome.yaml_util.load_yaml")
@patch("pathlib.Path.is_file")
def test_packages_skip_update_true(
mock_is_file: MagicMock, mock_load_yaml: MagicMock, mock_clone_or_update: MagicMock
) -> None:
"""Test that packages don't update when skip_update=True."""
# Setup mocks
mock_clone_or_update.return_value = (Path("/tmp/test"), None)
mock_is_file.return_value = True
mock_load_yaml.return_value = OrderedDict({"sensor": []})
config = {
CONF_PACKAGES: {
"test_package": {
CONF_URL: "https://github.com/test/repo",
CONF_FILES: ["test.yaml"],
CONF_REFRESH: "1d",
}
}
}
# Call with skip_update=True
do_packages_pass(config, skip_update=True)
# Verify clone_or_update was called with refresh=None
mock_clone_or_update.assert_called_once()
call_args = mock_clone_or_update.call_args
assert call_args.kwargs["refresh"] is None
@patch("esphome.git.clone_or_update")
@patch("esphome.yaml_util.load_yaml")
@patch("pathlib.Path.is_file")
def test_packages_skip_update_false(
mock_is_file: MagicMock, mock_load_yaml: MagicMock, mock_clone_or_update: MagicMock
) -> None:
"""Test that packages update when skip_update=False."""
# Setup mocks
mock_clone_or_update.return_value = (Path("/tmp/test"), None)
mock_is_file.return_value = True
mock_load_yaml.return_value = OrderedDict({"sensor": []})
config = {
CONF_PACKAGES: {
"test_package": {
CONF_URL: "https://github.com/test/repo",
CONF_FILES: ["test.yaml"],
CONF_REFRESH: "1d",
}
}
}
# Call with skip_update=False (default)
do_packages_pass(config, skip_update=False)
# Verify clone_or_update was called with actual refresh value
mock_clone_or_update.assert_called_once()
call_args = mock_clone_or_update.call_args
assert call_args.kwargs["refresh"] == "1d"
@patch("esphome.git.clone_or_update")
@patch("esphome.yaml_util.load_yaml")
@patch("pathlib.Path.is_file")
def test_packages_default_no_skip(
mock_is_file: MagicMock, mock_load_yaml: MagicMock, mock_clone_or_update: MagicMock
) -> None:
"""Test that packages update by default when skip_update not specified."""
# Setup mocks
mock_clone_or_update.return_value = (Path("/tmp/test"), None)
mock_is_file.return_value = True
mock_load_yaml.return_value = OrderedDict({"sensor": []})
config = {
CONF_PACKAGES: {
"test_package": {
CONF_URL: "https://github.com/test/repo",
CONF_FILES: ["test.yaml"],
CONF_REFRESH: "1d",
}
}
}
# Call without skip_update parameter
do_packages_pass(config)
# Verify clone_or_update was called with actual refresh value
mock_clone_or_update.assert_called_once()
call_args = mock_clone_or_update.call_args
assert call_args.kwargs["refresh"] == "1d"