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

Python common.init_recorder_component函数代码示例

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

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



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

示例1: test_load_from_db

    def test_load_from_db(self):
        """Test bootstrapping the brightness history from the database.

        This test can should only be executed if the loading of the history
        is enabled via plant.ENABLE_LOAD_HISTORY.
        """
        init_recorder_component(self.hass)
        plant_name = 'wise_plant'
        for value in [20, 30, 10]:

            self.hass.states.set(BRIGHTNESS_ENTITY, value,
                                 {ATTR_UNIT_OF_MEASUREMENT: 'Lux'})
            self.hass.block_till_done()
        # wait for the recorder to really store the data
        self.hass.data[recorder.DATA_INSTANCE].block_till_done()

        assert setup_component(self.hass, plant.DOMAIN, {
            plant.DOMAIN: {
                plant_name: GOOD_CONFIG
            }
        })
        self.hass.block_till_done()

        state = self.hass.states.get('plant.'+plant_name)
        self.assertEqual(STATE_UNKNOWN, state.state)
        max_brightness = state.attributes.get(
            plant.ATTR_MAX_BRIGHTNESS_HISTORY)
        self.assertEqual(30, max_brightness)
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:28,代码来源:test_plant.py


示例2: 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


示例3: test_initialize_from_database

    def test_initialize_from_database(self):
        """Test initializing the statistics from the database."""
        # enable the recorder
        init_recorder_component(self.hass)
        # store some values
        for value in self.values:
            self.hass.states.set('sensor.test_monitored', value,
                                 {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
            self.hass.block_till_done()
        # wait for the recorder to really store the data
        self.hass.data[recorder.DATA_INSTANCE].block_till_done()
        # only now create the statistics component, so that it must read the
        # data from the database
        assert setup_component(self.hass, 'sensor', {
            'sensor': {
                'platform': 'statistics',
                'name': 'test',
                'entity_id': 'sensor.test_monitored',
                'sampling_size': 100,
            }
        })

        self.hass.start()
        self.hass.block_till_done()

        # check if the result is as in test_sensor_source()
        state = self.hass.states.get('sensor.test_mean')
        assert str(self.mean) == state.state
开发者ID:Martwall,项目名称:home-assistant,代码行数:28,代码来源:test_statistics.py


示例4: setup_recorder

 def setup_recorder(config=None):
     """Set up with params."""
     init_recorder_component(hass, config)
     hass.start()
     hass.block_till_done()
     hass.data[DATA_INSTANCE].block_till_done()
     return hass
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:7,代码来源:test_init.py


示例5: setup_recorder

 def setup_recorder(config=None):
     """Setup with params."""
     init_recorder_component(hass, config)
     hass.start()
     hass.block_till_done()
     recorder.get_instance().block_till_done()
     return hass
开发者ID:danieljkemp,项目名称:home-assistant,代码行数:7,代码来源:test_init.py


示例6: init_recorder

 def init_recorder(self):
     """Initialize the recorder."""
     init_recorder_component(self.hass)
     self.hass.start()
     recorder.get_instance().block_till_db_ready()
     self.hass.block_till_done()
     recorder.get_instance().block_till_done()
开发者ID:danieljkemp,项目名称:home-assistant,代码行数:7,代码来源:test_history_stats.py


示例7: setUp

 def setUp(self):
     """Setup things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     init_recorder_component(self.hass)  # Force an in memory DB
     mock_http_component(self.hass)
     self.hass.config.components |= set(['frontend', 'recorder', 'api'])
     assert setup_component(self.hass, logbook.DOMAIN,
                            self.EMPTY_CONFIG)
     self.hass.start()
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:9,代码来源:test_logbook.py


示例8: setUp

 def setUp(self):  # pylint: disable=invalid-name
     """Setup things to be run when tests are started."""
     config = {'purge_keep_days': 4, 'purge_interval': 2}
     self.hass = get_test_home_assistant()
     init_recorder_component(self.hass, config)
     self.hass.start()
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:6,代码来源:test_purge.py


示例9: init_recorder

 def init_recorder(self):
     """Initialize the recorder."""
     init_recorder_component(self.hass)
     self.hass.start()
     self.wait_recording_done()
开发者ID:chuchock,项目名称:home-assistant,代码行数:5,代码来源:test_history.py


示例10: setUp

 def setUp(self):
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     init_recorder_component(self.hass)  # Force an in memory DB
     assert setup_component(self.hass, logbook.DOMAIN, self.EMPTY_CONFIG)
     self.hass.start()
开发者ID:tmcarr,项目名称:home-assistant,代码行数:6,代码来源:test_logbook.py


示例11: setUp

 def setUp(self):  # pylint: disable=invalid-name
     """Set up things to be run when tests are started."""
     self.hass = get_test_home_assistant()
     init_recorder_component(self.hass)
     self.hass.start()
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:5,代码来源:test_init.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.load_check函数代码示例发布时间:2022-05-27
下一篇:
Python common.get_test_instance_port函数代码示例发布时间: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