Blink tests complete, camera module next
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
import constants as const
|
||||
|
||||
"""Fake device attributes."""
|
||||
NETWORKS_RESPONSE = {}
|
||||
NETWORKS_RESPONSE['summary'] = {'onboarded': True, 'name': 'Nilfgaard'}
|
||||
NETWORKS_RESPONSE['networks'] = [{'network_key': None,
|
||||
'name': NETWORKS_RESPONSE['summary']['name'],
|
||||
'account_id': 1989,
|
||||
'id': 9898,
|
||||
'encryption_key': None,
|
||||
'armed': True,
|
||||
'ping_interval': 60,
|
||||
'video_destination': 'server',
|
||||
'arm_string': 'Armed',
|
||||
'feature_plan_id': None}]
|
||||
|
||||
FIRST_CAMERA = {'device_type': 'camera',
|
||||
'notifications': 1,
|
||||
'battery': 2,
|
||||
'active': 'enabled',
|
||||
'enabled': True,
|
||||
'temp': 70,
|
||||
'updated_at': '2017-01-01T01:23:45+00:00',
|
||||
'lfr_strength': 3,
|
||||
'armed': True,
|
||||
'device_id': 2112,
|
||||
'wifi_strength': 5,
|
||||
'thumbnail': '/this/is/url1/thumb',
|
||||
'name': 'First Camera',
|
||||
'status': 'done'}
|
||||
|
||||
SECOND_CAMERA = {'device_type': 'camera',
|
||||
'notifications': 0,
|
||||
'battery': 3,
|
||||
'active': 'disabled',
|
||||
'enabled': False,
|
||||
'temp': 82,
|
||||
'updated_at': '2017-12-21T01:21:12+00:00',
|
||||
'lfr_strength': 1,
|
||||
'armed': False,
|
||||
'device_id': 1221,
|
||||
'wifi_strength': 1,
|
||||
'thumbnail': '/this/is/url2/thumb',
|
||||
'name': 'Second Camera',
|
||||
'status': 'done'}
|
||||
|
||||
SYNC_MODULE = {'updated_at': '1970-01-01T01:00:00+00:00',
|
||||
'device_type': 'sync_module',
|
||||
'notifications': 2,
|
||||
'device_id': 7990,
|
||||
'status': 'online'}
|
||||
|
||||
FIRST_EVENT = {'camera_name': FIRST_CAMERA['name'],
|
||||
'updated_at': '2017-10-10T03:37:37+00:00',
|
||||
'sync_module_id': None,
|
||||
'camera': FIRST_CAMERA['device_id'],
|
||||
'type': 'motion',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at': '2017-01-28T19:51:52+00:00',
|
||||
'camera_id': FIRST_CAMERA['device_id'],
|
||||
'id': 666777888,
|
||||
'siren_id': None,
|
||||
'account_id': NETWORKS_RESPONSE['networks'][0]['account_id'],
|
||||
'notified': True,
|
||||
'siren': None,
|
||||
'syncmodule': None,
|
||||
'video_url': FIRST_CAMERA['thumbnail'] + '.mp4',
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': NETWORKS_RESPONSE['networks'][0]['account_id'],
|
||||
'video_id': 123000321}
|
||||
|
||||
SECOND_EVENT = {'updated_at': '2017-01-28T19:51:29+00:00',
|
||||
'sync_module_id': SYNC_MODULE['device_id'],
|
||||
'camera': None,
|
||||
'type': 'armed',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at': '2017-01-28T19:51:29+00:00',
|
||||
'camera_id': None,
|
||||
'id': 333777555,
|
||||
'siren_id': None,
|
||||
'account_id': NETWORKS_RESPONSE['networks'][0]['account_id'],
|
||||
'notified': False,
|
||||
'siren': None,
|
||||
'syncmodule': SYNC_MODULE['device_id'],
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': NETWORKS_RESPONSE['networks'][0]['account_id']}
|
||||
|
||||
|
||||
"""Fake response content."""
|
||||
LOGIN_RESPONSE = {}
|
||||
LOGIN_RESPONSE['region'] = {'ciri': 'Cintra'}
|
||||
LOGIN_RESPONSE['networks'] = {NETWORKS_RESPONSE['networks'][0]['id'] : NETWORKS_RESPONSE['summary']}
|
||||
LOGIN_RESPONSE['authtoken'] = {'authtoken': 'foobar7117', 'message': 'auth'}
|
||||
|
||||
RESPONSE = {}
|
||||
RESPONSE['account'] = {'notifications': SYNC_MODULE['notifications']}
|
||||
RESPONSE['devices'] = [FIRST_CAMERA, SECOND_CAMERA, SYNC_MODULE]
|
||||
RESPONSE['network'] = {'armed': NETWORKS_RESPONSE['networks'][0]['armed'],
|
||||
'wifi_strength': 4,
|
||||
'warning': 0,
|
||||
'name': NETWORKS_RESPONSE['summary']['name'],
|
||||
'notifications': SYNC_MODULE['notifications']}
|
||||
RESPONSE['event'] = [FIRST_EVENT, SECOND_EVENT]
|
||||
RESPONSE['syncmodule'] = {'name': 'Vengerberg', 'status': 'online'}
|
||||
|
||||
|
||||
def mocked_requests_post(*args, **kwargs):
|
||||
"""Mock post request."""
|
||||
class MockPostResponse:
|
||||
def __init__(self,json_data,status_code):
|
||||
self.json_data = json_data
|
||||
self.status_code = status_code
|
||||
def json(self):
|
||||
return self.json_data
|
||||
|
||||
url_tail = args[0].split("/")[-1]
|
||||
if args[0] == const.LOGIN_URL:
|
||||
return MockPostResponse(LOGIN_RESPONSE, 200)
|
||||
elif url_tail == 'arm' or url_tail == 'disarm':
|
||||
global NETWORKS_RESPONSE
|
||||
global RESPONSE
|
||||
NETWORKS_RESPONSE['networks'][0]['armed'] = url_tail == 'arm'
|
||||
RESPONSE['network']['armed'] = NETWORKS_RESPONSE['networks'][0]['armed']
|
||||
return MockPostResponse({}, 200)
|
||||
|
||||
return MockPostResponse({'message':'ERROR','code':404}, 404)
|
||||
|
||||
def mocked_requests_get(*args, **kwargs):
|
||||
"""Mock get request."""
|
||||
class MockGetResponse:
|
||||
def __init__(self,json_data,status_code):
|
||||
self.json_data = json_data
|
||||
self.status_code = status_code
|
||||
def json(self):
|
||||
return self.json_data
|
||||
|
||||
(region_id, region), = LOGIN_RESPONSE['region'].items()
|
||||
set_region_id = args[0].split('/')[2].split('.')[0]
|
||||
NETURL = 'https://' + set_region_id + '.' + const.BLINK_URL + '/networks'
|
||||
if args[0] == NETURL:
|
||||
return MockGetResponse(NETWORKS_RESPONSE, 200)
|
||||
elif set_region_id != region_id:
|
||||
raise ConnectionError('Received url ' + args[0])
|
||||
else:
|
||||
return MockGetResponse(RESPONSE, 200)
|
||||
|
||||
return MockGetResponse({'message':'ERROR','code':404}, 404)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# TODO
|
||||
@@ -1,101 +0,0 @@
|
||||
import blinkpy
|
||||
import requests
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from blinkpy import LOGIN_URL
|
||||
from blinkpy import BASE_URL
|
||||
import test_const as const
|
||||
|
||||
def mocked_requests_post(*args, **kwargs):
|
||||
class MockPostResponse:
|
||||
def __init__(self,json_data,status_code):
|
||||
self.json_data = json_data
|
||||
self.status_code = status_code
|
||||
def json(self):
|
||||
return self.json_data
|
||||
|
||||
if args[0] == LOGIN_URL:
|
||||
return MockPostResponse({"region":{const.REGION_ID: const.REGION}, "authtoken":{"authtoken":const.TOKEN}}, 200)
|
||||
elif args[0].split("/")[-1] == 'arm':
|
||||
return MockPostResponse({"armed":True}, 200)
|
||||
elif args[0].split("/")[-1] == 'disarm':
|
||||
return MockPostResponse({"armed":False}, 200)
|
||||
else:
|
||||
return MockPostResponse({}, 200)
|
||||
|
||||
return MockPostResponse({'message':'ERROR','code':404}, 404)
|
||||
|
||||
def mocked_requests_get(*args, **kwargs):
|
||||
class MockGetResponse:
|
||||
def __init__(self,json_data,status_code):
|
||||
self.json_data = json_data
|
||||
self.status_code = status_code
|
||||
def json(self):
|
||||
return self.json_data
|
||||
|
||||
if args[0] == BASE_URL + '/networks':
|
||||
return MockGetResponse({'networks':[{"id":const.NETWORK_ID,"account_id":const.ACCOUNT_ID},{"nothing":"nothing"}]}, 200)
|
||||
else:
|
||||
return MockGetResponse(const.response, 200)
|
||||
|
||||
|
||||
return MockGetResponse({'message':'ERROR','code':404}, 404)
|
||||
|
||||
class TestBlinkRequests(unittest.TestCase):
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mocked_requests_get)
|
||||
def test_blink_setup(self, mock_get, mock_post):
|
||||
blink = blinkpy.Blink(username='user',password='password')
|
||||
blink.setup_system()
|
||||
|
||||
self.assertEqual(blink.network_id, str(const.NETWORK_ID))
|
||||
self.assertEqual(blink.account_id, str(const.ACCOUNT_ID))
|
||||
self.assertEqual(blink.region, const.REGION)
|
||||
self.assertEqual(blink.region_id, const.REGION_ID)
|
||||
self.assertEqual(blink.online, const.ISONLINE)
|
||||
self.assertEqual(blink.arm, const.ARMED)
|
||||
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mocked_requests_get)
|
||||
def test_blink_camera_setup_and_motion(self, mock_get, mock_post):
|
||||
blink = blinkpy.Blink(username='user',password='password')
|
||||
blink.setup_system()
|
||||
blink.last_motion()
|
||||
for name, camera in blink.cameras.items():
|
||||
if camera.id == str(const.DEVICE_ID):
|
||||
self.assertEqual(name, const.CAMERA_NAME)
|
||||
self.assertEqual(camera.armed, const.ARMED)
|
||||
self.assertEqual(camera.motion['video'], BASE_URL + const.THUMB + '.mp4')
|
||||
self.assertEqual(camera.header, const.auth_header)
|
||||
elif camera.id == str(const.DEVICE_ID2):
|
||||
self.assertEqual(name, const.CAMERA_NAME2)
|
||||
self.assertEqual(camera.armed, const.ARMED2)
|
||||
self.assertEqual(len(camera.motion.keys()), 0)
|
||||
else:
|
||||
assert False is True
|
||||
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mocked_requests_get)
|
||||
def test_blink_refresh(self, mock_get, mock_post):
|
||||
blink = blinkpy.Blink(username='user',password='password')
|
||||
blink.setup_system()
|
||||
const.response['devices'][0]['thumbnail'] = const.THUMB + const.THUMB2
|
||||
blink.refresh()
|
||||
for name, camera in blink.cameras.items():
|
||||
if camera.id == str(const.DEVICE_ID):
|
||||
self.assertEqual(camera.thumbnail, BASE_URL + const.THUMB + const.THUMB2 + '.jpg')
|
||||
elif camera.id == str(const.DEVICE_ID2):
|
||||
pass
|
||||
else:
|
||||
assert False is True
|
||||
|
||||
const.response['devices'][0]['thumbnail'] = 'new'
|
||||
blink.cameras[const.CAMERA_NAME].image_refresh()
|
||||
for name, camera in blink.cameras.items():
|
||||
if camera.id == str(const.DEVICE_ID):
|
||||
self.assertEqual(camera.thumbnail, BASE_URL + 'new' + '.jpg')
|
||||
elif camera.id == str(const.DEVICE_ID2):
|
||||
pass
|
||||
else:
|
||||
assert False is True
|
||||
|
||||
+80
-15
@@ -1,7 +1,8 @@
|
||||
import requests
|
||||
import unittest
|
||||
import blinkpy
|
||||
from unittest import mock
|
||||
import blinkpy
|
||||
import tests.mock_responses as mresp
|
||||
import constants as const
|
||||
|
||||
USERNAME = 'foobar'
|
||||
@@ -9,35 +10,99 @@ PASSWORD = 'deadbeef'
|
||||
|
||||
class TestBlinkSetup(unittest.TestCase):
|
||||
"""Test the Blink class in blinkpy."""
|
||||
def setUp(self):
|
||||
"""Set up Blink module."""
|
||||
self.blink_no_cred = blinkpy.Blink()
|
||||
self.blink = blinkpy.Blink(username=USERNAME,
|
||||
password=PASSWORD)
|
||||
|
||||
def tearDown(self):
|
||||
"""Clean up after test."""
|
||||
self.blink = None
|
||||
self.blink_no_cred = None
|
||||
|
||||
def test_initialization(self):
|
||||
"""Verify we can initialize blink."""
|
||||
blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
|
||||
self.assertEqual(blink._username, USERNAME)
|
||||
self.assertEqual(blink._password, PASSWORD)
|
||||
self.assertEqual(self.blink._username, USERNAME)
|
||||
self.assertEqual(self.blink._password, PASSWORD)
|
||||
|
||||
def test_no_credentials(self):
|
||||
"""Check that we throw an exception when no username/password."""
|
||||
blink = blinkpy.Blink()
|
||||
with self.assertRaises(blinkpy.BlinkAuthenticationException):
|
||||
blink.get_auth_token()
|
||||
self.blink_no_cred.get_auth_token()
|
||||
with self.assertRaises(blinkpy.BlinkAuthenticationException):
|
||||
blink.setup_system()
|
||||
self.blink_no_cred.setup_system()
|
||||
|
||||
def test_no_auth_header(self):
|
||||
"""Check that we throw an excpetion when no auth header given."""
|
||||
blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
|
||||
(region_id, region), = mresp.LOGIN_RESPONSE['region'].items()
|
||||
self.blink.urls = blinkpy.BlinkURLHandler(region_id)
|
||||
with self.assertRaises(blinkpy.BlinkException):
|
||||
blink.get_ids()
|
||||
self.blink.get_ids()
|
||||
|
||||
@mock.patch('blinkpy.getpass.getpass')
|
||||
def test_manual_login(self, getpwd):
|
||||
"""Check that we can manually use the login() function."""
|
||||
blink = blinkpy.Blink()
|
||||
getpwd.return_value = PASSWORD
|
||||
with mock.patch('builtins.input', return_value=USERNAME):
|
||||
blink.login()
|
||||
self.assertEqual(blink._username, USERNAME)
|
||||
self.assertEqual(blink._password, PASSWORD)
|
||||
self.blink_no_cred.login()
|
||||
self.assertEqual(self.blink_no_cred._username, USERNAME)
|
||||
self.assertEqual(self.blink_no_cred._password, PASSWORD)
|
||||
|
||||
# NEXT NEED ACTUAL REQUEST TESTS
|
||||
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mresp.mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mresp.mocked_requests_get)
|
||||
def test_full_setup(self, mock_get, mock_post):
|
||||
"""Check that we can set Blink up properly."""
|
||||
self.blink.setup_system()
|
||||
|
||||
# Get all test values
|
||||
authtoken = mresp.LOGIN_RESPONSE['authtoken']['authtoken']
|
||||
(region_id, region), = mresp.LOGIN_RESPONSE['region'].items()
|
||||
host = region_id + '.' + const.BLINK_URL
|
||||
network_id = mresp.NETWORKS_RESPONSE['networks'][0]['id']
|
||||
account_id = mresp.NETWORKS_RESPONSE['networks'][0]['account_id']
|
||||
TestURLs = blinkpy.BlinkURLHandler(region_id)
|
||||
TestCameras = list()
|
||||
TestCameraID = dict()
|
||||
for element in mresp.RESPONSE['devices']:
|
||||
if 'device_type' in element and element['device_type'] == 'camera':
|
||||
TestCameras.append(element['name'])
|
||||
TestCameraID[str(element['device_id'])] = element['name']
|
||||
|
||||
# Check that all links have been set properly
|
||||
self.assertEqual(self.blink.region_id, region_id)
|
||||
self.assertEqual(self.blink.urls.base_url, TestURLs.base_url)
|
||||
self.assertEqual(self.blink.urls.home_url, TestURLs.home_url)
|
||||
self.assertEqual(self.blink.urls.event_url, TestURLs.event_url)
|
||||
self.assertEqual(self.blink.urls.network_url, TestURLs.network_url)
|
||||
self.assertEqual(self.blink.urls.networks_url, TestURLs.networks_url)
|
||||
|
||||
# Check that all properties have been set after startup
|
||||
self.assertEqual(self.blink._token, authtoken)
|
||||
self.assertEqual(self.blink._host, host)
|
||||
self.assertEqual(self.blink.network_id, str(network_id))
|
||||
self.assertEqual(self.blink.account_id, str(account_id))
|
||||
self.assertEqual(self.blink.region, region)
|
||||
|
||||
# Verify we have initialized all the cameras
|
||||
self.assertEqual(self.blink.id_table, TestCameraID)
|
||||
for camera in TestCameras:
|
||||
self.assertTrue(camera in self.blink.cameras)
|
||||
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mresp.mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mresp.mocked_requests_get)
|
||||
def test_arm_disarm_system(self, mock_get, mock_post):
|
||||
"""Check that we can arm/disarm the system"""
|
||||
self.blink.setup_system()
|
||||
self.blink.arm = False
|
||||
self.assertIs(self.blink.arm, False)
|
||||
self.blink.arm = True
|
||||
self.assertIs(self.blink.arm, True)
|
||||
|
||||
@mock.patch('blinkpy.requests.post', side_effect=mresp.mocked_requests_post)
|
||||
@mock.patch('blinkpy.requests.get', side_effect=mresp.mocked_requests_get)
|
||||
def test_check_online_status(self, mock_get, mock_post):
|
||||
"""Check that we can get our online status."""
|
||||
self.blink.setup_system()
|
||||
expected_status = const.ONLINE[mresp.RESPONSE['syncmodule']['status']]
|
||||
self.assertIs(self.blink.online, expected_status)
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
import testtools
|
||||
import unittest
|
||||
import blinkpy
|
||||
from blinkpy import BASE_URL
|
||||
|
||||
class TestBlink(unittest.TestCase):
|
||||
def test_blink_instance(self):
|
||||
blink = blinkpy.Blink()
|
||||
|
||||
def test_blink_camera_attributes(self):
|
||||
config = {'name':'name', 'device_id': 1248, 'armed':True, 'thumbnail':'/test/url/image', 'temp':70, 'battery':3, 'notifications':0, 'region_id':'rid'}
|
||||
|
||||
camera = blinkpy.BlinkCamera(config)
|
||||
|
||||
# Check that values are properly stored and can be recalled
|
||||
self.assertEqual(camera.name, config['name'])
|
||||
self.assertEqual(camera.id, str(config['device_id']))
|
||||
self.assertEqual(camera.armed, config['armed'])
|
||||
self.assertEqual(camera.clip, BASE_URL + config['thumbnail'] + '.mp4')
|
||||
self.assertEqual(camera.thumbnail, BASE_URL + config['thumbnail'] + '.jpg')
|
||||
self.assertEqual(camera.temperature, config['temp'])
|
||||
self.assertEqual(camera.battery, config['battery'])
|
||||
self.assertEqual(camera.notifications, config['notifications'])
|
||||
self.assertEqual(camera.region_id, config['region_id'])
|
||||
|
||||
# Check that values can be changed with individual methods
|
||||
test_header = {'Header':'test','Test':'1234'}
|
||||
test_img = 'http://image-link.com'
|
||||
test_arm = 'http://arm-link.com'
|
||||
test_motion = {'video':'url','image':'url','time':'timestamp'}
|
||||
|
||||
camera.name = config['name']+'_new'
|
||||
camera.clip = BASE_URL + config['thumbnail'] + '.mp4_new'
|
||||
camera.thumbnail = BASE_URL + config['thumbnail'] + '.jpg_new'
|
||||
camera.temperature = config['temp'] + 10
|
||||
camera.battery = config['battery'] + 1
|
||||
camera.notifications = config['notifications'] + 1
|
||||
camera.image_link = test_img
|
||||
camera.arm_link = test_arm
|
||||
camera.header = test_header
|
||||
camera.motion = test_motion
|
||||
|
||||
# Check that values are properly stored and can be recalled
|
||||
self.assertEqual(camera.name , config['name']+'_new')
|
||||
self.assertEqual(camera.clip , BASE_URL + config['thumbnail'] + '.mp4_new')
|
||||
self.assertEqual(camera.thumbnail, BASE_URL + config['thumbnail'] + '.jpg_new')
|
||||
self.assertEqual(camera.temperature, config['temp'] + 10)
|
||||
self.assertEqual(camera.battery, config['battery'] + 1)
|
||||
self.assertEqual(camera.notifications, config['notifications'] + 1)
|
||||
self.assertEqual(camera.image_link, test_img)
|
||||
self.assertEqual(camera.arm_link, test_arm)
|
||||
self.assertEqual(camera.header, test_header)
|
||||
self.assertEqual(camera.motion, test_motion)
|
||||
|
||||
# Verify bulk update function
|
||||
test_name = camera.name +' last'
|
||||
test_status = True
|
||||
test_url = '-this-is-a-test/for_realz'
|
||||
test_temp = camera.temperature + 7
|
||||
test_battery = camera.battery - 1
|
||||
test_notif = camera.notifications - 1
|
||||
values = {'name':test_name, 'armed':test_status, 'thumbnail':test_url, 'temp':test_temp, 'battery':test_battery, 'notifications':test_notif}
|
||||
|
||||
camera.update(values)
|
||||
# Check that values are properly stored and can be recalled
|
||||
jpg_url = BASE_URL + test_url +'.jpg'
|
||||
mp4_url = BASE_URL + test_url +'.mp4'
|
||||
self.assertEqual(camera.name, test_name)
|
||||
self.assertEqual(camera.armed, test_status)
|
||||
self.assertEqual(camera.clip, mp4_url)
|
||||
self.assertEqual(camera.thumbnail, jpg_url)
|
||||
self.assertEqual(camera.temperature, test_temp)
|
||||
self.assertEqual(camera.battery, test_battery)
|
||||
self.assertEqual(camera.notifications, test_notif)
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
ISONLINE = True
|
||||
ARMED = True
|
||||
ARMED2 = False
|
||||
REGION_ID = 'test'
|
||||
REGION = 'Oceaniaeurasia'
|
||||
TOKEN = 'abcd1234$$@@'
|
||||
NETWORK_ID = 1337
|
||||
DEVICE_ID = 9876
|
||||
DEVICE_ID2 = 6789
|
||||
ACCOUNT_ID = 1234
|
||||
CAMERA_NAME = 'My Camera'
|
||||
CAMERA_NAME2 = 'Number 2'
|
||||
BATTERY = 3
|
||||
BATTERY2 = 1
|
||||
TEMP = 70
|
||||
TEMP2 = 66
|
||||
THUMB = '/url/camera/7777/clip'
|
||||
THUMB2 = '/url/camera/8888/clip'
|
||||
NOTIFS = 1
|
||||
NOTIFS2 = 1
|
||||
SYNC_ID = 1000
|
||||
|
||||
if ISONLINE:
|
||||
ONLINE = 'online'
|
||||
else:
|
||||
ONLINE = 'offline'
|
||||
|
||||
auth_header = {'Host': REGION_ID+'.immedia-semi.com',
|
||||
'TOKEN_AUTH': TOKEN
|
||||
}
|
||||
|
||||
response = {'account': {'notifications': 1},
|
||||
'devices': [{'device_type': 'camera',
|
||||
'notifications': NOTIFS,
|
||||
'battery': BATTERY,
|
||||
'active': 'disabled',
|
||||
'errors': 0,
|
||||
'error_msg': '',
|
||||
'enabled': False,
|
||||
'temp': TEMP,
|
||||
'updated_at': '2017-01-27T03:14:24+00:00',
|
||||
'lfr_strength': 3,
|
||||
'armed': ARMED,
|
||||
'device_id': DEVICE_ID,
|
||||
'wifi_strength': 5,
|
||||
'warning': 0,
|
||||
'thumbnail': THUMB,
|
||||
'name': CAMERA_NAME,
|
||||
'status': 'done'},
|
||||
{'device_type': 'camera',
|
||||
'notifications': NOTIFS2,
|
||||
'battery': BATTERY2,
|
||||
'active': 'disabled',
|
||||
'errors': 0,
|
||||
'error_msg': '',
|
||||
'enabled': False,
|
||||
'temp': TEMP2,
|
||||
'updated_at': '2017-01-27T03:14:24+00:00',
|
||||
'lfr_strength': 3,
|
||||
'armed': ARMED2,
|
||||
'device_id': DEVICE_ID2,
|
||||
'wifi_strength': 5,
|
||||
'warning': 0,
|
||||
'thumbnail': THUMB2,
|
||||
'name': CAMERA_NAME2,
|
||||
'status': 'done'},
|
||||
{'updated_at': '2017-01-26T19:32:10+00:00',
|
||||
'device_type': 'sync_module',
|
||||
'notifications': 0,
|
||||
'device_id': SYNC_ID,
|
||||
'status':
|
||||
'online',
|
||||
'last_hb':
|
||||
'2017-01-27T03:14:49+00:00',
|
||||
'errors': 0,
|
||||
'error_msg': '',
|
||||
'warning': 0}],
|
||||
'network': {'armed': ARMED,
|
||||
'wifi_strength': 5,
|
||||
'warning': 0,
|
||||
'error_msg': '',
|
||||
'name': 'Blink',
|
||||
'notifications': NOTIFS,
|
||||
'status': 'ok'},
|
||||
'event': [{'camera_name': CAMERA_NAME,
|
||||
'updated_at': '2017-01-28T19:51:52+00:00',
|
||||
'sync_module_id': None,
|
||||
'camera': DEVICE_ID,
|
||||
'type': 'motion',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at': '2017-01-28T19:51:52+00:00',
|
||||
'camera_id': DEVICE_ID,
|
||||
'id': 123456789,
|
||||
'siren_id': None,
|
||||
'account_id': ACCOUNT_ID,
|
||||
'notified': True,
|
||||
'siren': None,
|
||||
'syncmodule': None,
|
||||
'video_url': THUMB+'.mp4',
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': ACCOUNT_ID,
|
||||
'video_id': 100000001},
|
||||
{'updated_at': '2017-01-28T19:51:29+00:00',
|
||||
'sync_module_id': SYNC_ID,
|
||||
'camera': None,
|
||||
'type': 'armed',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at':
|
||||
'2017-01-28T19:51:29+00:00',
|
||||
'camera_id': None,
|
||||
'id': 123456789,
|
||||
'siren_id': None,
|
||||
'account_id': ACCOUNT_ID,
|
||||
'notified': False,
|
||||
'siren': None,
|
||||
'syncmodule': SYNC_ID,
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': ACCOUNT_ID},
|
||||
{'updated_at': '2017-01-28T19:00:12+00:00',
|
||||
'sync_module_id': SYNC_ID,
|
||||
'camera': None,
|
||||
'type': 'disarmed',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at': '2017-01-28T19:00:12+00:00',
|
||||
'camera_id': None,
|
||||
'id': 123456789,
|
||||
'siren_id': None,
|
||||
'account_id': 2463,
|
||||
'notified': False,
|
||||
'siren': None,
|
||||
'syncmodule': SYNC_ID,
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': ACCOUNT_ID},
|
||||
{'camera_name': CAMERA_NAME,
|
||||
'updated_at': '2017-01-28T18:59:55+00:00',
|
||||
'sync_module_id': None,
|
||||
'camera': DEVICE_ID,
|
||||
'type': 'motion',
|
||||
'duration': None,
|
||||
'status': None,
|
||||
'created_at': '2017-01-28T18:59:55+00:00',
|
||||
'camera_id': DEVICE_ID,
|
||||
'id': 123456789,
|
||||
'siren_id': None,
|
||||
'account_id': ACCOUNT_ID,
|
||||
'notified': True,
|
||||
'siren': None,
|
||||
'syncmodule': None,
|
||||
'command_id': None,
|
||||
'network_id': None,
|
||||
'account': ACCOUNT_ID}],
|
||||
'syncmodule':{'name':'SyncName',
|
||||
'status':ONLINE}}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import testtools
|
||||
import blinkpy
|
||||
|
||||
class TestImport(testtools.TestCase):
|
||||
def test_import(self):
|
||||
pass
|
||||
@@ -1,8 +0,0 @@
|
||||
import requests
|
||||
import unittest
|
||||
from constants import BASE_URL
|
||||
|
||||
class TestRemoteServerResponse(unittest.TestCase):
|
||||
def test_request_response(self):
|
||||
response = requests.get(BASE_URL)
|
||||
self.assertEqual(response.ok, True)
|
||||
Reference in New Issue
Block a user