• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.get_test_home_assistant函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.common.get_test_home_assistant函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_home_assistant函数的具体用法?Python get_test_home_assistant怎么用?Python get_test_home_assistant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_test_home_assistant函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_platform_validator

def test_platform_validator():
    """Test platform validation."""
    # Prepares loading
    get_test_home_assistant()

    schema = vol.Schema(cv.platform_validator('light'))

    with pytest.raises(vol.MultipleInvalid):
        schema('platform_that_does_not_exist')

    schema('hue')
开发者ID:1lann,项目名称:home-assistant,代码行数:11,代码来源:test_config_validation.py


示例2: setUp

    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.events = []
        self.service1 = MagicMock()
        self.service2 = MagicMock()

        def mock_get_service(hass, config):
            if config['name'] == 'demo1':
                return self.service1
            else:
                return self.service2

        with assert_setup_component(2), \
                patch.object(demo, 'get_service', mock_get_service):
            setup_component(self.hass, notify.DOMAIN, {
                'notify': [{
                    'name': 'demo1',
                    'platform': 'demo'
                }, {
                    'name': 'demo2',
                    'platform': 'demo'
                }]
            })

        self.service = group.get_service(self.hass, {'services': [
            {'service': 'demo1'},
            {'service': 'demo2',
             'data': {'target': 'unnamed device',
                      'data': {'test': 'message'}}}]})

        assert self.service is not None
开发者ID:DavidLP,项目名称:home-assistant,代码行数:32,代码来源:test_group.py


示例3: setup_method

    def setup_method(self):
        """Set up things to be run when tests are started."""
        self.hass = get_test_home_assistant()

        config = {
            ip.DOMAIN: {
                'platform': 'demo'
            },
            'camera': {
                'platform': 'demo'
            },
        }

        with patch('homeassistant.components.image_processing.demo.'
                   'DemoImageProcessingFace.should_poll',
                   new_callable=PropertyMock(return_value=False)):
            setup_component(self.hass, ip.DOMAIN, config)

        state = self.hass.states.get('camera.demo_camera')
        self.url = "{0}{1}".format(
            self.hass.config.api.base_url,
            state.attributes.get(ATTR_ENTITY_PICTURE))

        self.face_events = []

        @callback
        def mock_face_event(event):
            """Mock event."""
            self.face_events.append(event)

        self.hass.bus.listen('image_processing.detect_face', mock_face_event)
开发者ID:ManHammer,项目名称:home-assistant,代码行数:31,代码来源:test_init.py


示例4: setUp

    def setUp(self):  # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.events = []
        self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
            'notify': [{
                'name': 'demo1',
                'platform': 'demo'
            }, {
                'name': 'demo2',
                'platform': 'demo'
            }]
        }))

        self.service = group.get_service(self.hass, {'services': [
            {'service': 'demo1'},
            {'service': 'demo2',
             'data': {'target': 'unnamed device',
                      'data': {'test': 'message'}}}]})

        assert self.service is not None

        def record_event(event):
            """Record event to send notification."""
            self.events.append(event)

        self.hass.bus.listen("notify", record_event)
开发者ID:PollieKrismis,项目名称:home-assistant,代码行数:27,代码来源:test_group.py


示例5: setUp

 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.mailer = MockSMTP('localhost', 25, 5, '[email protected]', 1,
                            'testuser', 'testpass',
                            ['[email protected]', '[email protected]'],
                            'HomeAssistant', 0)
开发者ID:ManHammer,项目名称:home-assistant,代码行数:7,代码来源:test_smtp.py


示例6: setup_method

 def setup_method(self, method):
     """Setup things to be run when tests are started."""
     self.entity = entity.Entity()
     self.entity.entity_id = 'test.overwrite_hidden_true'
     self.hass = self.entity.hass = get_test_home_assistant()
     self.entity.schedule_update_ha_state()
     self.hass.block_till_done()
开发者ID:Khabi,项目名称:home-assistant,代码行数:7,代码来源:test_entity.py


示例7: setup_method

 def setup_method(self, method):
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.rs = cmd_rs.CommandCover(self.hass, 'foo',
                                   'command_open', 'command_close',
                                   'command_stop', 'command_state',
                                   None)
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:7,代码来源:test_command_line.py


示例8: test_remove_lib_on_upgrade

    def test_remove_lib_on_upgrade(self, mock_os, mock_shutil):
        """Test removal of library on upgrade."""
        ha_version = '0.7.0'

        mock_os.path.isdir = mock.Mock(return_value=True)

        mock_open = mock.mock_open()
        with mock.patch('homeassistant.config.open', mock_open, create=True):
            opened_file = mock_open.return_value
            opened_file.readline.return_value = ha_version

            self.hass = get_test_home_assistant()
            self.hass.config.path = mock.Mock()

            config_util.process_ha_config_upgrade(self.hass)

            hass_path = self.hass.config.path.return_value

            self.assertEqual(mock_os.path.isdir.call_count, 1)
            self.assertEqual(
                mock_os.path.isdir.call_args, mock.call(hass_path)
            )

            self.assertEqual(mock_shutil.rmtree.call_count, 1)
            self.assertEqual(
                mock_shutil.rmtree.call_args, mock.call(hass_path)
            )
开发者ID:krzynio,项目名称:home-assistant,代码行数:27,代码来源:test_config.py


示例9: setup_method

 def setup_method(self, method):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.hass.config.latitude = 32.87336
     self.hass.config.longitude = 117.22743
     self.port = mock.MagicMock()
     self.switch = mfi.MfiSwitch(self.port)
开发者ID:bdfoster,项目名称:blumate,代码行数:7,代码来源:test_mfi.py


示例10: setUp

    def setUp(self):     # pylint: disable=invalid-name
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()
        self.hass.states.set("light.Bowl", "on")
        self.hass.states.set("switch.AC", "off")

        event_decorators.HASS = self.hass
开发者ID:bdfoster,项目名称:blumate,代码行数:7,代码来源:test_event_decorators.py


示例11: setUp

    def setUp(self):  # pylint: disable=invalid-name
        """ Init needed objects. """
        self.hass = get_test_home_assistant()
        self.assertTrue(comps.setup(self.hass, {}))

        self.hass.states.set('light.Bowl', STATE_ON)
        self.hass.states.set('light.Ceiling', STATE_OFF)
开发者ID:100dayproject,项目名称:home-assistant,代码行数:7,代码来源:test_init.py


示例12: setUp

    def setUp(self):  # pylint: disable=invalid-name
        """ Init needed objects. """
        self.hass = get_test_home_assistant()
        loader.prepare(self.hass)

        self.known_dev_path = self.hass.config.path(
            device_tracker.KNOWN_DEVICES_FILE)
开发者ID:michaelarnauts,项目名称:home-assistant,代码行数:7,代码来源:test_device_tracker.py


示例13: setUp

 def setUp(self):  # pylint: disable=invalid-name
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     self.hass.config.units = METRIC_SYSTEM
     self.assertTrue(hvac.setup(self.hass, {'hvac': {
         'platform': 'demo',
     }}))
开发者ID:MicSimoen,项目名称:home-assistant,代码行数:7,代码来源:test_demo.py


示例14: setUp

 def setUp(self):
     """Initialize values for this testcase class."""
     self.hass = get_test_home_assistant()
     self.key = 'foo'
     self.lat = self.hass.config.latitude = 37.8267
     self.lon = self.hass.config.longitude = -122.423
     self.entities = []
开发者ID:Martwall,项目名称:home-assistant,代码行数:7,代码来源:test_darksky.py


示例15: setUp

 def setUp(self):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     controller_mock = mock.MagicMock()
     dev_dict = {'address': 'a1', 'name': 'fake_switch'}
     self.switch = mochad.MochadSwitch(self.hass, controller_mock,
                                       dev_dict)
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:7,代码来源:test_mochad.py


示例16: setUpModule

def setUpModule():  # pylint: disable=invalid-name
    """Initalization of a Home Assistant server and Slave instance."""
    global hass, slave, master_api

    hass = get_test_home_assistant()

    hass.bus.listen("test_event", lambda _: _)
    hass.states.set("test.test", "a_state")

    bootstrap.setup_component(
        hass, http.DOMAIN, {http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD, http.CONF_SERVER_PORT: MASTER_PORT}}
    )

    bootstrap.setup_component(hass, "api")

    hass.start()
    time.sleep(0.05)

    master_api = remote.API("127.0.0.1", API_PASSWORD, MASTER_PORT)

    # Start slave
    loop = asyncio.new_event_loop()

    # FIXME: should not be a daemon
    threading.Thread(name="SlaveThread", daemon=True, target=loop.run_forever).start()

    slave = remote.HomeAssistant(master_api, loop=loop)
    slave.config.config_dir = get_test_config_dir()
    slave.config.skip_pip = True
    bootstrap.setup_component(
        slave, http.DOMAIN, {http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD, http.CONF_SERVER_PORT: SLAVE_PORT}}
    )

    with patch.object(ha, "_async_create_timer", return_value=None):
        slave.start()
开发者ID:krzynio,项目名称:home-assistant,代码行数:35,代码来源:test_remote.py


示例17: test_filling_the_cache

def test_filling_the_cache():
    """Test filling the cache from the DB."""
    test_entity_id1 = 'input_boolean.b1'
    test_entity_id2 = 'input_boolean.b2'

    hass = get_test_home_assistant()
    hass.state = CoreState.starting

    init_recorder_component(hass)

    _add_data_in_last_run(hass, {
        test_entity_id1: 'on',
        test_entity_id2: 'off',
    })

    hass.block_till_done()
    setup_component(hass, input_boolean.DOMAIN, {
        input_boolean.DOMAIN: {
            'b1': None,
            'b2': None,
        }})

    hass.start()

    state = hass.states.get('input_boolean.b1')
    assert state
    assert state.state == 'on'

    state = hass.states.get('input_boolean.b2')
    assert state
    assert state.state == 'off'

    hass.stop()
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:33,代码来源:test_restore_state.py


示例18: setUp

    def setUp(self):  # pylint: disable=invalid-name
        """Set up test variables."""
        serial_number = "12345"
        temperature_unit = "F"

        thermostat = Mock(
            serial_number=serial_number,
            room="Master bathroom",
            online=True,
            heating=True,
            temperature=2222,
            celsius=22,
            fahrenheit=72,
            max_celsius=69,
            max_fahrenheit=157,
            min_celsius=5,
            min_fahrenheit=41,
            schedule_mode=SCHEDULE_RUN,
            target_celsius=22,
            target_fahrenheit=72)

        thermostat.get_data = Mock()
        thermostat.resume_schedule = Mock()

        self.api = Mock()
        self.api.get_thermostat.return_value = thermostat

        self.hass = get_test_home_assistant()
        self.thermostat = nuheat.NuHeatThermostat(
            self.api, serial_number, temperature_unit)
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:30,代码来源:test_nuheat.py


示例19: setUp

    def setUp(self):
        """Setup things to be run when tests are started."""
        self.hass = get_test_home_assistant()

        # Set our timezone to CST/Regina so we can check calculations
        # This keeps UTC-6 all year round
        dt_util.set_default_time_zone(dt_util.get_time_zone('America/Regina'))
开发者ID:GadgetReactor,项目名称:home-assistant,代码行数:7,代码来源:test_google.py


示例20: setUpModule

def setUpModule():   # pylint: disable=invalid-name
    """Initalization of a Home Assistant server and Slave instance."""
    global hass, slave, master_api

    hass = get_test_home_assistant()

    hass.bus.listen('test_event', lambda _: _)
    hass.states.set('test.test', 'a_state')

    bootstrap.setup_component(
        hass, http.DOMAIN,
        {http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
         http.CONF_SERVER_PORT: MASTER_PORT}})

    bootstrap.setup_component(hass, 'api')

    hass.start()

    master_api = remote.API("127.0.0.1", API_PASSWORD, MASTER_PORT)

    # Start slave
    slave = remote.HomeAssistant(master_api)
    bootstrap.setup_component(
        slave, http.DOMAIN,
        {http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
         http.CONF_SERVER_PORT: SLAVE_PORT}})

    slave.start()
开发者ID:1lann,项目名称:home-assistant,代码行数:28,代码来源:test_remote.py



注:本文中的tests.common.get_test_home_assistant函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.get_test_instance_port函数代码示例发布时间:2022-05-27
下一篇:
Python common.get_test_config_dir函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap