Exemplo n.º 1
0
 def setUp(self):
     """Set up Blink module."""
     self.blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
     # pylint: disable=protected-access
     self.blink._auth_header = {
         'Host': 'test.url.tld',
         'TOKEN_AUTH': 'foobar123'
     }
     self.blink.urls = blinkpy.BlinkURLHandler('test')
     self.config = {
         'device_id': 1111,
         'name': 'foobar',
         'armed': False,
         'active': 'disabled',
         'thumbnail': '/test',
         'video': '/test.mp4',
         'temp': 80,
         'battery': 3,
         'notifications': 2,
         'region_id': 'test',
         'device_type': 'camera'
     }
     self.blink.sync = MockSyncModule(self.blink, self.blink._auth_header)
     self.blink.session = create_session()
     self.camera = BlinkCamera(self.config, self.blink.sync)
Exemplo n.º 2
0
 def setUp(self):
     """Set up Blink module."""
     self.blink = blinkpy.Blink(username=USERNAME,
                                password=PASSWORD,
                                motion_interval=0)
     # pylint: disable=protected-access
     self.blink._auth_header = {
         "Host": "test.url.tld",
         "TOKEN_AUTH": "foobar123"
     }
     self.blink.last_refresh = 0
     self.blink.urls = blinkpy.BlinkURLHandler("test")
     self.blink.sync["test"] = BlinkSyncModule(self.blink, "test", "1234",
                                               [])
     self.camera = BlinkCamera(self.blink.sync)
     self.mock_start = [
         {
             "syncmodule": {
                 "id": 1234,
                 "network_id": 5678,
                 "serial": "12345678",
                 "status": "foobar",
             }
         },
         {
             "event": True
         },
         {},
         {},
         None,
         {
             "devicestatus": {}
         },
     ]
     self.blink.sync["test"].network_info = {"network": {"armed": True}}
Exemplo n.º 3
0
 def setUp(self):
     """Set up Blink module."""
     self.blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
     # pylint: disable=protected-access
     self.blink._auth_header = {
         'Host': 'test.url.tld',
         'TOKEN_AUTH': 'foobar123'
     }
     self.blink.urls = blinkpy.BlinkURLHandler('test')
     self.blink.sync['test'] = BlinkSyncModule(self.blink, 'test', '1234',
                                               [])
     self.camera = BlinkCamera(self.blink.sync)
     self.mock_start = [
         {
             'syncmodule': {
                 'id': 1234,
                 'network_id': 5678,
                 'serial': '12345678',
                 'status': 'foobar'
             }
         },
         {
             'event': True
         },
         {},
         {},
         None,
         {
             'devicestatus': {}
         },
     ]
Exemplo n.º 4
0
    def test_camera_attributes(self, mock_cfg):
        """Tests camera attributes."""
        self.blink.urls = blinkpy.BlinkURLHandler('test')

        self.blink.cameras = {
            'foobar': blinkpy.BlinkCamera(self.camera_config, self.blink)
        }

        for name in self.blink.cameras:
            camera = self.blink.cameras[name]
            camera.update(self.camera_config)
            camera_attr = camera.attributes
            self.assertEqual(camera_attr['device_id'], '1111')
            self.assertEqual(camera_attr['name'], 'foobar')
            self.assertEqual(camera_attr['armed'], False)
            self.assertEqual(
                camera_attr['thumbnail'],
                "https://rest.test.{}/test/image.jpg".format(BLINK_URL)
            )
            self.assertEqual(
                camera_attr['video'],
                "https://rest.test.{}/test/clip/clip.mp4".format(BLINK_URL)
            )
            self.assertEqual(camera_attr['temperature'], 68)
            self.assertEqual(camera_attr['temperature_c'], 20.0)
            self.assertEqual(camera_attr['battery'], 50)
            self.assertEqual(camera_attr['notifications'], 2)
            self.assertEqual(camera_attr['network_id'], '0000')
            self.assertEqual(camera_attr['motion_detected'], True)
            self.assertEqual(camera_attr['wifi_strength'], -30)
Exemplo n.º 5
0
    def test_camera_properties(self, mock_get, mock_post, mock_cfg):
        """Tests all property set/recall."""
        self.blink.urls = blinkpy.BlinkURLHandler('test')

        self.blink.cameras = {
            'foobar': blinkpy.BlinkCamera(self.camera_config, self.blink)
        }

        for name in self.blink.cameras:
            camera = self.blink.cameras[name]
            camera.update(self.camera_config)
            self.assertEqual(camera.id, '1111')
            self.assertEqual(camera.name, 'foobar')
            self.assertEqual(camera.armed, False)
            self.assertEqual(
                camera.thumbnail,
                "https://rest.test.{}/test/image.jpg".format(BLINK_URL)
            )
            self.assertEqual(
                camera.clip,
                "https://rest.test.{}/test/clip/clip.mp4".format(BLINK_URL)
            )
            self.assertEqual(camera.temperature, 68)
            self.assertEqual(camera.temperature_c, 20.0)
            self.assertEqual(camera.battery, 50)
            self.assertEqual(camera.battery_string, "OK")
            self.assertEqual(camera.notifications, 2)
            self.assertEqual(camera.region_id, 'test')
            self.assertEqual(camera.motion_detected, True)
            self.assertEqual(camera.wifi_strength, -30)

        camera_config = self.camera_config
        camera_config['active'] = 'armed'
        camera_config['thumbnail'] = '/test2/image'
        camera_config['video'] = '/test2/clip.mp4'
        camera_config['temp'] = 60
        camera_config['battery'] = 0
        camera_config['notifications'] = 4
        for name in self.blink.cameras:
            camera = self.blink.cameras[name]
            camera.update(camera_config)
            self.assertEqual(camera.armed, True)
            self.assertEqual(
                camera.thumbnail,
                "https://rest.test.{}/test2/image.jpg".format(BLINK_URL)
            )
            self.assertEqual(
                camera.clip,
                "https://rest.test.{}/test2/clip.mp4".format(BLINK_URL)
            )
            self.assertEqual(camera.temperature, 68)
            self.assertEqual(camera.battery, 50)
            self.assertEqual(camera.battery_string, "Low")
            self.assertEqual(camera.notifications, 4)
            camera_config['battery'] = -10
            camera.update(camera_config)
            self.assertEqual(camera.battery_string, "Unknown")
Exemplo n.º 6
0
 def setUp(self):
     """Set up Blink module."""
     self.blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
     # pylint: disable=protected-access
     self.blink._auth_header = {
         'Host': 'test.url.tld',
         'TOKEN_AUTH': 'foobar123'
     }
     self.blink.urls = blinkpy.BlinkURLHandler('test')
     self.blink.session = create_session()
Exemplo n.º 7
0
 def test_no_auth_header(self):
     """Check that we throw an exception when no auth header given."""
     # pylint: disable=unused-variable
     (region_id, region), = mresp.LOGIN_RESPONSE['region'].items()
     self.blink.urls = blinkpy.BlinkURLHandler(region_id)
     with self.assertRaises(blinkpy.BlinkException):
         self.blink.get_ids()
     with self.assertRaises(blinkpy.BlinkException):
         # pylint: disable=protected-access
         self.blink._summary_request()
Exemplo n.º 8
0
 def setUp(self):
     """Set up Blink module."""
     self.blink = blinkpy.Blink(username=USERNAME,
                                password=PASSWORD)
     # pylint: disable=protected-access
     self.blink._auth_header = {
         'Host': 'test.url.tld',
         'TOKEN_AUTH': 'foobar123'
     }
     self.blink.urls = blinkpy.BlinkURLHandler('test')
     self.blink.sync['test'] = BlinkSyncModule(self.blink, 'test', '1234')
     self.camera = BlinkCamera(self.blink.sync)
Exemplo n.º 9
0
    def setUp(self):
        """Set up Blink module."""
        self.blink = blinkpy.Blink(username=USERNAME,
                                   password=PASSWORD)
        self.camera_config = {
            'device_id': 1111,
            'name': 'foobar',
            'armed': False,
            'active': 'disarmed',
            'thumbnail': '/test/image',
            'video': '/test/clip/clip.mp4',
            'temp': 70,
            'battery': 3,
            'notifications': 2,
            'region_id': 'test'
        }

        self.blink.urls = blinkpy.BlinkURLHandler('test')
        self.blink.network_id = '0000'