Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
720d520398 | ||
|
|
8fb1116641 | ||
|
|
c319762152 | ||
|
|
726d8b8c65 | ||
|
|
cf65648293 | ||
|
|
130aa8382a |
+7
-2
@@ -43,7 +43,8 @@ class Blink():
|
||||
|
||||
def __init__(self, username=None, password=None,
|
||||
refresh_rate=DEFAULT_REFRESH,
|
||||
motion_interval=DEFAULT_MOTION_INTERVAL):
|
||||
motion_interval=DEFAULT_MOTION_INTERVAL,
|
||||
legacy_subdomain=False):
|
||||
"""
|
||||
Initialize Blink system.
|
||||
|
||||
@@ -55,6 +56,9 @@ class Blink():
|
||||
Defaults to last refresh time.
|
||||
Useful for preventing motion_detected property
|
||||
from de-asserting too quickly.
|
||||
:param legacy_subdomain: Set to TRUE to use old 'rest.region'
|
||||
endpoints (only use if you are having
|
||||
api issues).
|
||||
"""
|
||||
self._username = username
|
||||
self._password = password
|
||||
@@ -76,6 +80,7 @@ class Blink():
|
||||
self._login_url = LOGIN_URL
|
||||
self.motion_interval = DEFAULT_MOTION_INTERVAL
|
||||
self.version = __version__
|
||||
self.legacy = legacy_subdomain
|
||||
|
||||
@property
|
||||
def auth_header(self):
|
||||
@@ -139,7 +144,7 @@ class Blink():
|
||||
|
||||
self._auth_header = {'Host': self._host,
|
||||
'TOKEN_AUTH': self._token}
|
||||
self.urls = BlinkURLHandler(self.region_id)
|
||||
self.urls = BlinkURLHandler(self.region_id, legacy=self.legacy)
|
||||
|
||||
return self._auth_header
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 14
|
||||
PATCH_VERSION = '0.dev1'
|
||||
PATCH_VERSION = '0.dev2'
|
||||
|
||||
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
|
||||
|
||||
|
||||
@@ -111,9 +111,12 @@ class BlinkAuthenticationException(BlinkException):
|
||||
class BlinkURLHandler():
|
||||
"""Class that handles Blink URLS."""
|
||||
|
||||
def __init__(self, region_id):
|
||||
def __init__(self, region_id, legacy=False):
|
||||
"""Initialize the urls."""
|
||||
self.base_url = "https://rest.{}.{}".format(region_id, BLINK_URL)
|
||||
self.subdomain = 'rest-{}'.format(region_id)
|
||||
if legacy:
|
||||
self.subdomain = 'rest.{}'.format(region_id)
|
||||
self.base_url = "https://{}.{}".format(self.subdomain, BLINK_URL)
|
||||
self.home_url = "{}/homescreen".format(self.base_url)
|
||||
self.event_url = "{}/events/network".format(self.base_url)
|
||||
self.network_url = "{}/network".format(self.base_url)
|
||||
|
||||
@@ -93,9 +93,9 @@ class TestBlinkCameraSetup(unittest.TestCase):
|
||||
self.assertEqual(self.camera.temperature_calibrated, 71)
|
||||
self.assertEqual(self.camera.wifi_strength, 4)
|
||||
self.assertEqual(self.camera.thumbnail,
|
||||
'https://rest.test.immedia-semi.com/thumb.jpg')
|
||||
'https://rest-test.immedia-semi.com/thumb.jpg')
|
||||
self.assertEqual(self.camera.clip,
|
||||
'https://rest.test.immedia-semi.com/test.mp4')
|
||||
'https://rest-test.immedia-semi.com/test.mp4')
|
||||
self.assertEqual(self.camera.image_from_cache, 'test')
|
||||
self.assertEqual(self.camera.video_from_cache, 'foobar')
|
||||
|
||||
@@ -136,7 +136,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
|
||||
}
|
||||
self.camera.update(config)
|
||||
self.assertEqual(self.camera.thumbnail,
|
||||
'https://rest.test.immedia-semi.com/new/thumb.jpg')
|
||||
'https://rest-test.immedia-semi.com/new/thumb.jpg')
|
||||
|
||||
def test_no_thumbnails(self, mock_sess):
|
||||
"""Tests that thumbnail is 'None' if none found."""
|
||||
|
||||
+8
-1
@@ -3,7 +3,7 @@
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import time
|
||||
from blinkpy.helpers.util import Throttle
|
||||
from blinkpy.helpers.util import Throttle, BlinkURLHandler
|
||||
|
||||
|
||||
class TestUtil(unittest.TestCase):
|
||||
@@ -98,3 +98,10 @@ class TestUtil(unittest.TestCase):
|
||||
with mock.patch('time.time', return_value=now_plus_6):
|
||||
self.assertEqual(tester.test1(), None)
|
||||
self.assertEqual(tester.test2(), True)
|
||||
|
||||
def test_legacy_subdomains(self):
|
||||
"""Test that subdomain can be set to legacy mode."""
|
||||
urls = BlinkURLHandler('test')
|
||||
self.assertEqual(urls.subdomain, 'rest-test')
|
||||
urls = BlinkURLHandler('test', legacy=True)
|
||||
self.assertEqual(urls.subdomain, 'rest.test')
|
||||
|
||||
Reference in New Issue
Block a user