Extract requirements (#12051)
This commit is contained in:
parent
71cb4df817
commit
ec1c395f09
6 changed files with 160 additions and 131 deletions
|
@ -9,7 +9,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, CONSTRAINT_FILE
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START
|
||||
import homeassistant.config as config_util
|
||||
from homeassistant import setup, loader
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
@ -41,9 +41,6 @@ class TestSetup:
|
|||
"""Clean up."""
|
||||
self.hass.stop()
|
||||
|
||||
# if os.path.isfile(VERSION_PATH):
|
||||
# os.remove(VERSION_PATH)
|
||||
|
||||
def test_validate_component_config(self):
|
||||
"""Test validating component configuration."""
|
||||
config_schema = vol.Schema({
|
||||
|
@ -203,43 +200,6 @@ class TestSetup:
|
|||
assert not setup.setup_component(self.hass, 'comp')
|
||||
assert 'comp' not in self.hass.config.components
|
||||
|
||||
@mock.patch('homeassistant.setup.os.path.dirname')
|
||||
@mock.patch('homeassistant.util.package.running_under_virtualenv',
|
||||
return_value=True)
|
||||
@mock.patch('homeassistant.util.package.install_package',
|
||||
return_value=True)
|
||||
def test_requirement_installed_in_venv(
|
||||
self, mock_install, mock_venv, mock_dirname):
|
||||
"""Test requirement installed in virtual environment."""
|
||||
mock_venv.return_value = True
|
||||
mock_dirname.return_value = 'ha_package_path'
|
||||
self.hass.config.skip_pip = False
|
||||
loader.set_component(
|
||||
'comp', MockModule('comp', requirements=['package==0.0.1']))
|
||||
assert setup.setup_component(self.hass, 'comp')
|
||||
assert 'comp' in self.hass.config.components
|
||||
assert mock_install.call_args == mock.call(
|
||||
'package==0.0.1',
|
||||
constraints=os.path.join('ha_package_path', CONSTRAINT_FILE))
|
||||
|
||||
@mock.patch('homeassistant.setup.os.path.dirname')
|
||||
@mock.patch('homeassistant.util.package.running_under_virtualenv',
|
||||
return_value=False)
|
||||
@mock.patch('homeassistant.util.package.install_package',
|
||||
return_value=True)
|
||||
def test_requirement_installed_in_deps(
|
||||
self, mock_install, mock_venv, mock_dirname):
|
||||
"""Test requirement installed in deps directory."""
|
||||
mock_dirname.return_value = 'ha_package_path'
|
||||
self.hass.config.skip_pip = False
|
||||
loader.set_component(
|
||||
'comp', MockModule('comp', requirements=['package==0.0.1']))
|
||||
assert setup.setup_component(self.hass, 'comp')
|
||||
assert 'comp' in self.hass.config.components
|
||||
assert mock_install.call_args == mock.call(
|
||||
'package==0.0.1', target=self.hass.config.path('deps'),
|
||||
constraints=os.path.join('ha_package_path', CONSTRAINT_FILE))
|
||||
|
||||
def test_component_not_setup_twice_if_loaded_during_other_setup(self):
|
||||
"""Test component setup while waiting for lock is not setup twice."""
|
||||
result = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue