|
发表于 2019-8-12 17:08:05
|
显示全部楼层
你下载整个项目,然后写一个插件把插件放到components目录下,这样就变成了一个官方插件,然后用官方的测试用例方案就能直接跑起来了,例如:
import unittest
from time import sleep
from homeassistant.setup import setup_component
from tests.common import get_test_home_assistant
VALID_CONFIG = {
'weather': {
'platform': 'hf_weather',
'name': "xxxx",
'city': 'CN101210113',# CN101210113,auto_ip
'appkey': 'xxxx',
}}
class TestSiementsSensor(unittest.TestCase):
"""Test the sigfox platform."""
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_valid_credentials(self):
"""Test for valid credentials."""
assert setup_component(self.hass, 'weather', VALID_CONFIG)
sleep(100)
assert len(self.hass.states.entity_ids()) == 2
state = self.hass.states.get('sensor.siemens_dock')
|
|