Do not mount deps folder when running in virtual env (#14993)
* Do not mount deps folder when inside virtual env * Add tests * Fix package test
This commit is contained in:
parent
3ee8f58fdf
commit
0b114f0755
5 changed files with 79 additions and 59 deletions
|
@ -9,7 +9,7 @@ import homeassistant.config as config_util
|
|||
from homeassistant import bootstrap
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import patch_yaml_files, get_test_config_dir
|
||||
from tests.common import patch_yaml_files, get_test_config_dir, mock_coro
|
||||
|
||||
ORIG_TIMEZONE = dt_util.DEFAULT_TIME_ZONE
|
||||
VERSION_PATH = os.path.join(get_test_config_dir(), config_util.VERSION_FILE)
|
||||
|
@ -52,3 +52,55 @@ def test_home_assistant_core_config_validation(hass):
|
|||
}
|
||||
}, hass)
|
||||
assert result is None
|
||||
|
||||
|
||||
def test_from_config_dict_not_mount_deps_folder(loop):
|
||||
"""Test that we do not mount the deps folder inside from_config_dict."""
|
||||
with patch('homeassistant.bootstrap.is_virtual_env', return_value=False), \
|
||||
patch('homeassistant.core.HomeAssistant',
|
||||
return_value=Mock(loop=loop)), \
|
||||
patch('homeassistant.bootstrap.async_mount_local_lib_path',
|
||||
return_value=mock_coro()) as mock_mount, \
|
||||
patch('homeassistant.bootstrap.async_from_config_dict',
|
||||
return_value=mock_coro()):
|
||||
|
||||
bootstrap.from_config_dict({}, config_dir='.')
|
||||
assert len(mock_mount.mock_calls) == 1
|
||||
|
||||
with patch('homeassistant.bootstrap.is_virtual_env', return_value=True), \
|
||||
patch('homeassistant.core.HomeAssistant',
|
||||
return_value=Mock(loop=loop)), \
|
||||
patch('homeassistant.bootstrap.async_mount_local_lib_path',
|
||||
return_value=mock_coro()) as mock_mount, \
|
||||
patch('homeassistant.bootstrap.async_from_config_dict',
|
||||
return_value=mock_coro()):
|
||||
|
||||
bootstrap.from_config_dict({}, config_dir='.')
|
||||
assert len(mock_mount.mock_calls) == 0
|
||||
|
||||
|
||||
async def test_async_from_config_file_not_mount_deps_folder(loop):
|
||||
"""Test that we not mount the deps folder inside async_from_config_file."""
|
||||
hass = Mock(async_add_job=Mock(side_effect=lambda *args: mock_coro()))
|
||||
|
||||
with patch('homeassistant.bootstrap.is_virtual_env', return_value=False), \
|
||||
patch('homeassistant.bootstrap.async_enable_logging',
|
||||
return_value=mock_coro()), \
|
||||
patch('homeassistant.bootstrap.async_mount_local_lib_path',
|
||||
return_value=mock_coro()) as mock_mount, \
|
||||
patch('homeassistant.bootstrap.async_from_config_dict',
|
||||
return_value=mock_coro()):
|
||||
|
||||
await bootstrap.async_from_config_file('mock-path', hass)
|
||||
assert len(mock_mount.mock_calls) == 1
|
||||
|
||||
with patch('homeassistant.bootstrap.is_virtual_env', return_value=True), \
|
||||
patch('homeassistant.bootstrap.async_enable_logging',
|
||||
return_value=mock_coro()), \
|
||||
patch('homeassistant.bootstrap.async_mount_local_lib_path',
|
||||
return_value=mock_coro()) as mock_mount, \
|
||||
patch('homeassistant.bootstrap.async_from_config_dict',
|
||||
return_value=mock_coro()):
|
||||
|
||||
await bootstrap.async_from_config_file('mock-path', hass)
|
||||
assert len(mock_mount.mock_calls) == 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue