Exemple #1
0
    def setup_environment(self):
        airplay_port = self.server.port

        services = []
        services.append(
            zeroconf_stub.homesharing_service(DMAP_ID, b"Apple TV 1", IP_1,
                                              b"aaaa"))
        services.append(
            zeroconf_stub.mrp_service(
                "DDDD",
                b"Apple TV 2",
                IP_2,
                MRP_ID,
                port=self.fake_atv.get_port(Protocol.MRP),
            ))
        services.append(
            zeroconf_stub.airplay_service("Apple TV 2",
                                          IP_2,
                                          AIRPLAY_ID,
                                          port=airplay_port))
        zeroconf_stub.stub(pyatv, *services)

        self.fake_udns.add_service(
            fake_udns.mrp_service("DDDD",
                                  "Apple TV 2",
                                  MRP_ID,
                                  port=self.fake_atv.get_port(Protocol.MRP)))
        self.fake_udns.add_service(
            fake_udns.airplay_service("Apple TV 2",
                                      AIRPLAY_ID,
                                      port=airplay_port))

        self.airplay_usecase.airplay_playback_playing()
        self.airplay_usecase.airplay_playback_idle()
Exemple #2
0
    def setup_environment(self):
        airplay_port = self.server.port

        services = []
        services.append(zeroconf_stub.homesharing_service(
                DMAP_ID, b'Apple TV 1', IP_1, b'aaaa'))
        services.append(zeroconf_stub.mrp_service(
                'DDDD', b'Apple TV 2', IP_2, MRP_ID, port=self.fake_atv.port))
        services.append(zeroconf_stub.airplay_service(
                'Apple TV 2', IP_2, AIRPLAY_ID, port=airplay_port))
        zeroconf_stub.stub(pyatv, *services)

        self.usecase.airplay_playback_playing()
        self.usecase.airplay_playback_idle()
Exemple #3
0
HSGID = 'hsgid'

MRP_ID_1 = 'mrp_id_1'
MRP_ID_2 = 'mrp_id_2'

AIRPLAY_ID = 'AA:BB:CC:DD:EE:FF'

HOMESHARING_SERVICE_1 = zeroconf_stub.homesharing_service(
    'AAAA', b'Apple TV 1', IP_1, b'aaaa')
HOMESHARING_SERVICE_2 = zeroconf_stub.homesharing_service(
    'BBBB', b'Apple TV 2', IP_2, b'bbbb')
HOMESHARING_SERVICE_3 = zeroconf_stub.homesharing_service(
    'CCCC', b'Apple TV\xC2\xA03', IP_3, b'cccc')
DEVICE_SERVICE_1 = zeroconf_stub.device_service('CCCC', b'Apple TV\xC2\xA03',
                                                IP_3)
MRP_SERVICE_1 = zeroconf_stub.mrp_service('DDDD', b'Apple TV 4', IP_4,
                                          MRP_ID_1)
MRP_SERVICE_2 = zeroconf_stub.mrp_service('EEEE', b'Apple TV 5', IP_5,
                                          MRP_ID_2)
AIRPLAY_SERVICE_1 = zeroconf_stub.airplay_service('Apple TV 6', IP_6,
                                                  AIRPLAY_ID)


def _get_atv(atvs, ip):
    for atv in atvs:
        if atv.address == ipaddress.ip_address(ip):
            return atv
    return None


class ScanZeroconfTest(asynctest.TestCase):
    async def test_scan_no_device_found(self):
Exemple #4
0
import pyatv
import ipaddress
import asynctest

from pyatv.conf import AppleTV
from tests import zeroconf_stub

HOMESHARING_SERVICE_1 = zeroconf_stub.homesharing_service(
    'AAAA', b'Apple TV 1', '10.0.0.1', b'aaaa')
HOMESHARING_SERVICE_2 = zeroconf_stub.homesharing_service(
    'BBBB', b'Apple TV 2', '10.0.0.2', b'bbbb')
HOMESHARING_SERVICE_3 = zeroconf_stub.homesharing_service(
    'CCCC', b'Apple TV 3', '10.0.0.3', b'cccc')
DEVICE_SERVICE_1 = zeroconf_stub.device_service('CCCC', b'Apple TV 3',
                                                '10.0.0.3')
MRP_SERVICE_1 = zeroconf_stub.mrp_service('DDDD', b'Apple TV 4', '10.0.0.4')
MRP_SERVICE_2 = zeroconf_stub.mrp_service('EEEE', b'Apple TV 5', '10.0.0.5')
AIRPLAY_SERVICE_1 = zeroconf_stub.airplay_service('Apple TV 6', '10.0.0.6')


class FunctionalTest(asynctest.TestCase):
    async def test_scan_no_device_found(self):
        zeroconf_stub.stub(pyatv)

        atvs = await pyatv.scan_for_apple_tvs(self.loop, timeout=0)
        self.assertEqual(len(atvs), 0)

    async def test_scan_for_apple_tvs(self):
        zeroconf_stub.stub(pyatv, HOMESHARING_SERVICE_1, HOMESHARING_SERVICE_2,
                           MRP_SERVICE_1, AIRPLAY_SERVICE_1)
Exemple #5
0
MRP_ID_1 = "mrp_id_1"
MRP_ID_2 = "mrp_id_2"

AIRPLAY_ID = "AA:BB:CC:DD:EE:FF"

HOMESHARING_SERVICE_1 = zeroconf_stub.homesharing_service(
    "AAAA", b"Apple TV 1", IP_1, b"aaaa"
)
HOMESHARING_SERVICE_2 = zeroconf_stub.homesharing_service(
    "BBBB", b"Apple TV 2", IP_2, b"bbbb"
)
HOMESHARING_SERVICE_3 = zeroconf_stub.homesharing_service(
    "CCCC", b"Apple TV\xC2\xA03", IP_3, b"cccc"
)
DEVICE_SERVICE_1 = zeroconf_stub.device_service("CCCC", b"Apple TV\xC2\xA03", IP_3)
MRP_SERVICE_1 = zeroconf_stub.mrp_service("DDDD", b"Apple TV 4", IP_4, MRP_ID_1)
MRP_SERVICE_2 = zeroconf_stub.mrp_service("EEEE", b"Apple TV 5", IP_5, MRP_ID_2)
AIRPLAY_SERVICE_1 = zeroconf_stub.airplay_service("Apple TV 6", IP_6, AIRPLAY_ID)
AIRPLAY_SERVICE_2 = zeroconf_stub.airplay_service("Apple TV 4", IP_4, AIRPLAY_ID)


def _get_atv(atvs, ip):
    for atv in atvs:
        if atv.address == ipaddress.ip_address(ip):
            return atv
    return None


def assert_device(atv, name, address, identifier, protocol, port, creds=None):
    assert atv.name == name
    assert atv.address == address