Пример #1
0
    def test_pair(self):
        """Test pair with device available."""

        mac = config['dev']['testdev1']['mac']
        bluew.pair(mac)
        paired = bluew.info(mac).Paired
        self.assertTrue(paired)
Пример #2
0
    def test_distrust(self):
        """Test distrust with device available."""

        mac = config['dev']['testdev1']['mac']
        bluew.distrust(mac)
        trusted = bluew.info(mac).Trusted
        self.assertFalse(trusted)
Пример #3
0
    def test_info(self):
        """Test info with device available."""

        mac = config['dev']['testdev1']['mac']
        resp = bluew.info(mac)
        self.assertTrue(resp)
        self.assertIsInstance(resp, bluew.Device)
        self.assertEqual(mac, resp.Address)
Пример #4
0
 def __getattribute__(self, item):
     # This hack queries the state of the device on attribute access, and
     # guarantees that all values returned are in fact up to date.
     # IMPORTANT NOTE: Thou shall not use `self.attr` access in this method,
     # or thou shall dive in an infinite recursion as deep as thy stack.
     # SERIOUSLY: `self.attr` is just gonna call this method again.
     if item not in Device.attrs:
         try:
             mac = super().__getattribute__('address')
             self = bluew.info(mac)  # noqa: F841
         except AttributeError as error:
             logger = logging.getLogger(__name__)
             logger.debug("Invalid device")
     return super().__getattribute__(item)