Пример #1
0
    def add_mrp_service(self, info, address):
        """Add a new MediaRemoteProtocol device to discovered list."""
        if self.protocol and self.protocol != PROTOCOL_MRP:
            return

        name = info.properties[b'Name'].decode('utf-8')
        self._handle_service(address, name, conf.MrpService(info.port))
Пример #2
0
 def _mrp_service(self, mdns_service: mdns.Service, response: mdns.Response) -> None:
     """Add a new MediaRemoteProtocol device to discovered list."""
     name = mdns_service.properties.get("Name", "Unknown")
     service = conf.MrpService(
         mdns_service.properties.get("UniqueIdentifier"),
         mdns_service.port,
         properties=mdns_service.properties,
     )
     self._handle_service(mdns_service.address, name, service, response)
Пример #3
0
 def setUp(self):
     self.config = conf.AppleTV(ADDRESS_1, NAME)
     self.dmap_service = conf.DmapService(IDENTIFIER_1, None, port=PORT_1)
     self.mrp_service = conf.MrpService(
         IDENTIFIER_2, PORT_2, properties=MRP_PROPERTIES
     )
     self.airplay_service = conf.AirPlayService(
         IDENTIFIER_3, PORT_1, properties=AIRPLAY_PROPERTIES
     )
Пример #4
0
def full_device(mock_scan, dmap_pin):
    """Mock pyatv.scan."""
    mock_scan.result.append(
        create_conf(
            "127.0.0.1",
            "MRP Device",
            conf.MrpService("mrp_id", 5555),
            conf.DmapService("dmap_id", None, port=6666),
            conf.AirPlayService("airplay_id", port=7777),
        ))
    yield mock_scan
Пример #5
0
    def test_to_str(self):
        self.atv.add_service(conf.DmapService('LOGIN_ID'))
        self.atv.add_service(conf.MrpService(PORT_2))

        # Check for some keywords to not lock up format too much
        output = str(self.atv)
        self.assertIn(ADDRESS_1, output)
        self.assertIn(NAME, output)
        self.assertIn('LOGIN_ID', output)
        self.assertIn(str(PORT_2), output)
        self.assertIn('3689', output)
Пример #6
0
    def test_to_str(self):
        self.config.add_service(conf.DmapService(IDENTIFIER_1, "LOGIN_ID"))
        self.config.add_service(conf.MrpService(IDENTIFIER_2, PORT_2))

        # Check for some keywords to not lock up format too much
        output = str(self.config)
        self.assertIn(ADDRESS_1, output)
        self.assertIn(NAME, output)
        self.assertIn("LOGIN_ID", output)
        self.assertIn(str(PORT_2), output)
        self.assertIn("3689", output)
Пример #7
0
def test_to_str(config):
    config.add_service(conf.DmapService(IDENTIFIER_1, "LOGIN_ID"))
    config.add_service(conf.MrpService(IDENTIFIER_2, PORT_2))

    # Check for some keywords to not lock up format too much
    output = str(config)
    assert ADDRESS_1 in output
    assert NAME in output
    assert "LOGIN_ID" in output
    assert str(PORT_2) in output
    assert "3689" in output
    assert "Deep Sleep: True" in output
Пример #8
0
    "model": "AppleTV6,2",
    "deviceid": "ff:ee:dd:cc:bb:aa",
    "osvers": "8.0.0",
}

RAOP_PROPERTIES = {
    "am": "AudioAccessory5,1",
    "ov": "14.5",
}

AIRPORT_PROPERTIES = {
    "am": "AirPort10,115",
}

DMAP_SERVICE = conf.DmapService(IDENTIFIER_1, None, port=PORT_1)
MRP_SERVICE = conf.MrpService(IDENTIFIER_2, PORT_2, properties=MRP_PROPERTIES)
AIRPLAY_SERVICE = conf.AirPlayService(IDENTIFIER_3,
                                      PORT_1,
                                      properties=AIRPLAY_PROPERTIES)
COMPANION_SERVICE = conf.CompanionService(PORT_3)
RAOP_SERVICE = conf.RaopService(IDENTIFIER_4,
                                PORT_4,
                                properties=RAOP_PROPERTIES)
AIRPORT_SERVICE = conf.RaopService(IDENTIFIER_1,
                                   PORT_1,
                                   properties=AIRPORT_PROPERTIES)


@pytest.fixture
def config():
    yield conf.AppleTV(ADDRESS_1,
Пример #9
0
def mrp_device(mock_scan):
    """Mock pyatv.scan."""
    mock_scan.result.append(
        create_conf("127.0.0.1", "MRP Device", conf.MrpService("mrp_id",
                                                               5555)))
    yield mock_scan
Пример #10
0
 def _mrp_service(self, _, address, port, properties):
     """Add a new MediaRemoteProtocol device to discovered list."""
     identifier = properties.get("UniqueIdentifier")
     name = properties.get("Name")
     service = conf.MrpService(identifier, port, properties=properties)
     self._handle_service(address, name, service)
Пример #11
0
 def setUp(self):
     self.config = conf.AppleTV(ADDRESS_1, NAME)
     self.dmap_service = conf.DmapService(IDENTIFIER_1, None, port=PORT_1)
     self.mrp_service = conf.MrpService(IDENTIFIER_2, PORT_2)
     self.airplay_service = conf.AirPlayService(IDENTIFIER_3, PORT_1)
Пример #12
0
 def _mrp_service(self, _, address, port, properties):
     """Add a new MediaRemoteProtocol device to discovered list."""
     identifier = _property_decode(properties, 'UniqueIdentifier')
     name = _property_decode(properties, 'Name')
     service = conf.MrpService(identifier, port)
     self._handle_service(address, name, service)