def setUp(self, patched_soap_request, patched_get): from openhomedevice.Device import Device global soap_request_calls self.sut = Device(self.LOCATION) soap_request_calls = [] return super().setUp()
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup Openhome Platform.""" from openhomedevice.Device import Device if discovery_info: _LOGGER.info('Openhome device found, (%s)', discovery_info[0]) device = Device(discovery_info[1]) # if device has already been discovered if device.Uuid() in [x.unique_id for x in DEVICES]: return True device = OpenhomeDevice(hass, device) add_devices([device], True) DEVICES.append(device) return True return True
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Openhome platform.""" if not discovery_info: return True name = discovery_info.get("name") description = discovery_info.get("ssdp_description") _LOGGER.info("Openhome device found: %s", name) device = Device(description) # if device has already been discovered if device.Uuid() in [x.unique_id for x in DEVICES]: return True device = OpenhomeDevice(hass, device) add_entities([device], True) DEVICES.append(device) return True
def testSubscribeAndUnsubscribeForTrackInfo(self): with patch('requests.get') as mock_request: mock_request.return_value.text = self.deviceXml device = Device(self.deviceUrl) with patch('requests.request') as mock_request: mock_request.return_value.status_code = 200 mock_request.return_value.headers = { "SID": "uuid:1", "TIMEOUT": "Second-60" } f = threading.Event() with patch('unittest.mock.Mock', side_effect=lambda *args, **kwargs: f.set()) as mock: sid = device.SubscribeTrackInfo(self.ownIp, self.port, mock, 60) mock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mock_socket.connect((self.ownIp, self.port)) mock_socket.sendall(self.upnpNotify) mock_socket.close() f.wait(5) device.UnsubscribeTrackInfo(sid) mock.assert_called_once()
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup Openhome Platform.""" from openhomedevice.Device import Device if not discovery_info: return True name = discovery_info.get('name') description = discovery_info.get('ssdp_description') _LOGGER.info('Openhome device found, (%s)', name) device = Device(description) # if device has already been discovered if device.Uuid() in [x.unique_id for x in DEVICES]: return True device = OpenhomeDevice(hass, device) add_devices([device], True) DEVICES.append(device) return True