mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Create progress file for pip installs (#24297)
* Create progress file for pip installs * fix dedlock * unflacky test * Address comments * Lint * Types
This commit is contained in:
committed by
Paulus Schoutsen
parent
d7c8adc085
commit
bf52aa8ccc
@@ -1,10 +1,11 @@
|
||||
"""Test requirements module."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, call
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.requirements import (
|
||||
CONSTRAINT_FILE, async_process_requirements)
|
||||
CONSTRAINT_FILE, async_process_requirements, PROGRESS_FILE, _install)
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, MockModule, mock_coro, mock_integration)
|
||||
@@ -143,3 +144,22 @@ async def test_install_on_docker(hass):
|
||||
constraints=os.path.join('ha_package_path', CONSTRAINT_FILE),
|
||||
no_cache_dir=True,
|
||||
)
|
||||
|
||||
|
||||
async def test_progress_lock(hass):
|
||||
"""Test an install attempt on an existing package."""
|
||||
progress_path = Path(hass.config.path(PROGRESS_FILE))
|
||||
kwargs = {'hello': 'world'}
|
||||
|
||||
def assert_env(req, **passed_kwargs):
|
||||
"""Assert the env."""
|
||||
assert progress_path.exists()
|
||||
assert req == 'hello'
|
||||
assert passed_kwargs == kwargs
|
||||
return True
|
||||
|
||||
with patch('homeassistant.util.package.install_package',
|
||||
side_effect=assert_env):
|
||||
_install(hass, 'hello', kwargs)
|
||||
|
||||
assert not progress_path.exists()
|
||||
|
||||
Reference in New Issue
Block a user