def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.opp.data.pop(DATA_CUSTOM_COMPONENTS) setup_component( self.opp, http.DOMAIN, {http.DOMAIN: { http.CONF_SERVER_PORT: get_test_instance_port() }}, ) config = { ip.DOMAIN: { "platform": "test" }, "camera": { "platform": "demo" } } setup_component(self.opp, ip.DOMAIN, config) self.opp.block_till_done() state = self.opp.states.get("camera.demo_camera") self.url = ( f"{self.opp.config.internal_url}{state.attributes.get(ATTR_ENTITY_PICTURE)}" )
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() assert setup_component(self.opp, lock.DOMAIN, {"lock": { "platform": "demo" }})
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() config = { ip.DOMAIN: { "platform": "demo" }, "camera": { "platform": "demo" } } with patch( "openpeerpower.components.demo.image_processing." "DemoImageProcessingFace.should_poll", new_callable=PropertyMock(return_value=False), ): setup_component(self.opp, ip.DOMAIN, config) self.opp.block_till_done() state = self.opp.states.get("camera.demo_camera") self.url = ( f"{self.opp.config.internal_url}{state.attributes.get(ATTR_ENTITY_PICTURE)}" ) self.face_events = [] @callback def mock_face_event(event): """Mock event.""" self.face_events.append(event) self.opp.bus.listen("image_processing.detect_face", mock_face_event)
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.config = {mf.DOMAIN: {"api_key": "12345678abcdef"}} self.endpoint_url = f"https://westus.{mf.FACE_API_URL}"
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.opp.config.units = METRIC_SYSTEM self.lat = self.opp.config.latitude = 37.8267 self.lon = self.opp.config.longitude = -122.423 self.addCleanup(self.tear_down_cleanup)
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() platform = getattr(self.opp.components, "test.switch") platform.init() # Switch 1 is ON, switch 2 is OFF self.switch_1, self.switch_2, self.switch_3 = platform.ENTITIES
def setup_method(self, method): """Set up things to be run when tests are started.""" self.entity = entity.Entity() self.entity.entity_id = "test.overwrite_hidden_true" self.opp = self.entity.opp = get_test_open_peer_power() self.entity.schedule_update_op_state() self.opp.block_till_done()
def setup_method(self): """Set up things to be run when tests are started.""" self.url = "https://example.com/" self.config = { rc.DOMAIN: { "get_test": { "url": self.url, "method": "get" }, "patch_test": { "url": self.url, "method": "patch" }, "post_test": { "url": self.url, "method": "post" }, "put_test": { "url": self.url, "method": "put" }, "delete_test": { "url": self.url, "method": "delete" }, } } self.opp = get_test_open_peer_power()
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() assert setup_component(self.opp, remote.DOMAIN, {"remote": { "platform": "demo" }})
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.opp.config.units = METRIC_SYSTEM assert setup_component( self.opp, weather.DOMAIN, {"weather": {"platform": "demo"}} )
def setUp(self): """Initialize values for this testcase class.""" self.opp = get_test_open_peer_power() self.mock_kira = MagicMock() self.opp.data[kira.DOMAIN] = {kira.CONF_REMOTE: {}} self.opp.data[kira.DOMAIN][kira.CONF_REMOTE]["kira"] = self.mock_kira self.addCleanup(self.opp.stop)
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.opp.config.units = IMPERIAL_SYSTEM assert setup_component(self.opp, water_heater.DOMAIN, {"water_heater": { "platform": "demo" }})
def setUp(self): """Initialize values for this testcase class.""" self.opp = get_test_open_peer_power() self.key = "foo" self.lat = self.opp.config.latitude = 37.8267 self.lon = self.opp.config.longitude = -122.423 self.entities = [] self.addCleanup(self.tear_down_cleanup)
def setUp(self): """Init values for this testcase class.""" self.opp = get_test_open_peer_power() self.configs = [ {CONF_SUBSCRIPTION: "576965", CONF_NAME: "A Server"}, {CONF_SUBSCRIPTION: "123456", CONF_NAME: "Failed Server"}, {CONF_SUBSCRIPTION: "555555", CONF_NAME: vultr.DEFAULT_NAME}, ] self.addCleanup(self.tear_down_cleanup)
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() assert asyncio.run_coroutine_threadsafe( async_setup_component(self.opp, "openpeerpower", {}), self.opp.loop).result() self.opp.states.set("light.Bowl", STATE_ON) self.opp.states.set("light.Ceiling", STATE_OFF)
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self._base_url = "https://tts.voicetech.yandex.net/generate?" asyncio.run_coroutine_threadsafe( async_process_op_core_config( self.opp, {"internal_url": "http://example.local:8123"}), self.opp.loop, )
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.config = { "binary_sensor": { "platform": "ffmpeg_motion", "input": "testinputvideo" } }
def setUp(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.opp.states.set( "test.indoortemp", "20", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) self.opp.states.set( "test.outdoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) self.opp.states.set( "test.indoorhumidity", "50", {ATTR_UNIT_OF_MEASUREMENT: "%"} )
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.events = [] self.calls = [] @callback def record_event(event): """Record event to send notification.""" self.events.append(event) self.opp.bus.listen(demo.EVENT_NOTIFY, record_event)
def test_service_disable_run_information_recorded(tmpdir): """Test that runs are still recorded when recorder is disabled.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" opp = get_test_open_peer_power() setup_component(opp, DOMAIN, {DOMAIN: {CONF_DB_URL: dburl}}) opp.start() wait_recording_done(opp) with session_scope(opp=opp) as session: db_run_info = list(session.query(RecorderRuns)) assert len(db_run_info) == 1 assert db_run_info[0].start is not None assert db_run_info[0].end is None assert opp.services.call( DOMAIN, SERVICE_DISABLE, {}, blocking=True, ) wait_recording_done(opp) opp.stop() opp = get_test_open_peer_power() setup_component(opp, DOMAIN, {DOMAIN: {CONF_DB_URL: dburl}}) opp.start() wait_recording_done(opp) with session_scope(opp=opp) as session: db_run_info = list(session.query(RecorderRuns)) assert len(db_run_info) == 2 assert db_run_info[0].start is not None assert db_run_info[0].end is not None assert db_run_info[1].start is not None assert db_run_info[1].end is None opp.stop()
def opp_recorder(): """Open Peer Power fixture with in-memory recorder.""" opp = get_test_open_peer_power() def setup_recorder(config=None): """Set up with params.""" init_recorder_component(opp, config) opp.start() opp.block_till_done() opp.data[DATA_INSTANCE].block_till_done() return opp yield setup_recorder opp.stop()
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.mailer = MockSMTP( "localhost", 25, 5, "*****@*****.**", 1, "testuser", "testpass", ["*****@*****.**", "*****@*****.**"], "Open Peer Power", 0, )
def setUpClass(cls): """Set up the class.""" cls.opp = opp = get_test_open_peer_power() setup.setup_component( opp, emulated_hue.DOMAIN, { emulated_hue.DOMAIN: { emulated_hue.CONF_LISTEN_PORT: BRIDGE_SERVER_PORT } }, ) cls.opp.start()
def setup_method(self, method): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() self.values = [17, 20, 15.2, 5, 3.8, 9.2, 6.7, 14, 6] self.count = len(self.values) self.min = min(self.values) self.max = max(self.values) self.total = sum(self.values) self.mean = round(sum(self.values) / len(self.values), 2) self.median = round(statistics.median(self.values), 2) self.deviation = round(statistics.stdev(self.values), 2) self.variance = round(statistics.variance(self.values), 2) self.change = round(self.values[-1] - self.values[0], 2) self.average_change = round(self.change / (len(self.values) - 1), 2) self.change_rate = round(self.change / (60 * (self.count - 1)), 2) self.addCleanup(self.opp.stop)
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() asyncio.run_coroutine_threadsafe( async_process_op_core_config( self.opp, {"internal_url": "http://example.local:8123"}), self.opp.loop, ) self.url = "https://api.voicerss.org/" self.form_data = { "key": "1234567xx", "hl": "en-us", "c": "MP3", "f": "8khz_8bit_mono", "src": "I person is on front of your door.", }
def test_setup_scanner_timeout(): """Test setup_scanner failure from timeout.""" opp = get_test_open_peer_power() opp.start() config = { "username": TEST_CALLSIGN, "password": TEST_PASSWORD, "host": "localhost", "timeout": 0.01, "callsigns": ["XX0FOO*", "YY0BAR-1"], } see = Mock() try: assert not device_tracker.setup_scanner(opp, config, see) finally: opp.stop()
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() config = { ip.DOMAIN: { "platform": "openalpr_cloud", "source": { "entity_id": "camera.demo_camera", "name": "test local" }, "region": "eu", "api_key": "sk_abcxyz123456", }, "camera": { "platform": "demo" }, } with patch( "openpeerpower.components.openalpr_cloud.image_processing." "OpenAlprCloudEntity.should_poll", new_callable=PropertyMock(return_value=False), ): setup_component(self.opp, ip.DOMAIN, config) self.opp.block_till_done() self.alpr_events = [] @callback def mock_alpr_event(event): """Mock event.""" self.alpr_events.append(event) self.opp.bus.listen("image_processing.found_plate", mock_alpr_event) self.params = { "secret_key": "sk_abcxyz123456", "tasks": "plate", "return_image": 0, "country": "eu", }
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() test_light = getattr(self.opp.components, "test.light") test_light.init() assert setup_component(self.opp, light.DOMAIN, {light.DOMAIN: { "platform": "test" }}) self.light_1, self.light_2 = test_light.ENTITIES[0:2] common_light.turn_off(self.opp, [self.light_1.entity_id, self.light_2.entity_id]) self.opp.block_till_done() assert not self.light_1.is_on assert not self.light_2.is_on
def opp_recorder(enable_statistics): """Open Peer Power fixture with in-memory recorder.""" opp = get_test_open_peer_power() stats = recorder.Recorder.async_hourly_statistics if enable_statistics else None with patch( "openpeerpower.components.recorder.Recorder.async_hourly_statistics", side_effect=stats, autospec=True, ): def setup_recorder(config=None): """Set up with params.""" init_recorder_component(opp, config) opp.start() opp.block_till_done() opp.data[recorder.DATA_INSTANCE].block_till_done() return opp yield setup_recorder opp.stop()
def setup_method(self): """Set up things to be run when tests are started.""" self.opp = get_test_open_peer_power() asyncio.run_coroutine_threadsafe( async_process_op_core_config( self.opp, {"internal_url": "http://example.local:8123"}), self.opp.loop, ) self.host = "localhost" self.port = 59125 self.params = { "INPUT_TEXT": "OpenPeerPower", "INPUT_TYPE": "TEXT", "OUTPUT_TYPE": "AUDIO", "LOCALE": "en_US", "AUDIO": "WAVE_FILE", "VOICE": "cmu-slt-hsmm", }