async def test_random_pairing_guid_generated(self): pairing.random.getrandbits = lambda x: RANDOM_128_BITS handler = pairing.DmapPairingHandler(self.loop) await handler.start(zeroconf=self.zeroconf, name='test') self.assertEqual(handler.credentials, RANDOM_PAIRING_GUID) await handler.stop()
async def setUp(self): self.zeroconf = zeroconf_stub.stub(pairing) self.pairing = pairing.DmapPairingHandler(self.loop) # TODO: currently stubs internal method, should provide stub # for netifaces later pairing._get_private_ip_addresses = \ lambda: [ipaddress.ip_address('10.0.0.1')]
async def test_random_pairing_guid_generated(self): pairing.random.getrandbits = lambda x: RANDOM_128_BITS handler = pairing.DmapPairingHandler(self.loop) await handler.set('pairing_guid', None) pairing_guid = await handler.get('credentials') self.assertEqual(pairing_guid, RANDOM_PAIRING_GUID)
async def _start(pin_code=PIN_CODE, pairing_guid=PAIRING_GUID, name=REMOTE_NAME): options = {"zeroconf": zeroconf} if pairing_guid: options["pairing_guid"] = pairing_guid if name: options["name"] = name obj.pairing = pairing.DmapPairingHandler(config, None, event_loop, **options) await obj.pairing.begin() obj.pairing.pin(pin_code) return obj.pairing, zeroconf, service
async def _start(self, pin_code=PIN_CODE, pairing_guid=PAIRING_GUID, name=REMOTE_NAME): options = {'zeroconf': self.zeroconf} if pairing_guid: options['pairing_guid'] = pairing_guid if name: options['name'] = name self.pairing = pairing.DmapPairingHandler(self.config, None, self.loop, **options) await self.pairing.begin() self.pairing.pin(pin_code)
def __init__(self, loop, session, details, airplay): """Initialize a new Apple TV.""" super().__init__() self._session = session self._dmap_service = details.get_service(const.PROTOCOL_DMAP) daap_http = HttpSession( session, 'http://{0}:{1}/'.format(details.address, self._dmap_service.port)) self._requester = DaapRequester(daap_http, self._dmap_service.device_credentials) self._apple_tv = BaseDmapAppleTV(self._requester) self._dmap_remote = DmapRemoteControl(self._apple_tv) self._dmap_metadata = DmapMetadata(self._apple_tv, daap_http) self._dmap_push_updater = DmapPushUpdater(loop, self._apple_tv) self._dmap_pairing = pairing.DmapPairingHandler(loop) self._airplay = airplay