本文整理汇总了Python中pywink.api.get_devices_from_response_dict函数的典型用法代码示例。如果您正苦于以下问题:Python get_devices_from_response_dict函数的具体用法?Python get_devices_from_response_dict怎么用?Python get_devices_from_response_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_devices_from_response_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_handle_porkfolio_response
def test_should_handle_porkfolio_response(self):
with open('{}/api_responses/porkfolio.json'.format(os.path.dirname(__file__))) as porkfolio_file:
response_dict = json.load(porkfolio_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.PIGGY_BANK])
self.assertEqual(2, len(devices))
self.assertIsInstance(devices[0], WinkCurrencySensor)
self.assertIsInstance(devices[1], WinkPorkfolioNose)
示例2: test_should_handle_power_strip_response
def test_should_handle_power_strip_response(self):
with open('{}/api_responses/power_strip.json'.format(os.path.dirname(__file__))) as powerstrip_file:
response_dict = json.load(powerstrip_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.POWER_STRIP])
self.assertEqual(2, len(devices))
self.assertIsInstance(devices[0], WinkPowerStripOutlet)
self.assertIsInstance(devices[1], WinkPowerStripOutlet)
示例3: test_gocontrol_motion_sensor_should_be_identified
def test_gocontrol_motion_sensor_should_be_identified(self):
response = ApiResponseJSONLoader('motion_sensor_gocontrol.json').load()
devices = get_devices_from_response_dict(response,
DEVICE_ID_KEYS[
device_types.SENSOR_POD])
self.assertEqual(1, len(devices))
self.assertIsInstance(devices[0], WinkSensorPod)
示例4: test_pubnub_key_and_channel_should_be_none
def test_pubnub_key_and_channel_should_be_none(self):
with open('{}/api_responses/lock.json'.format(os.path.dirname(__file__))) as lock_file:
response_dict = json.load(lock_file)
device = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.LOCK])[0]
self.assertIsNone(device.pubnub_key)
self.assertIsNone(device.pubnub_channel)
示例5: test_battery_level_should_return_float
def test_battery_level_should_return_float(self):
with open('{}/api_responses/quirky_spotter_2.json'.format(os.path.dirname(__file__))) as spotter_file:
response_dict = json.load(spotter_file)
sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
for sensor in sensors:
self.assertEqual(sensor.battery_level, 0.86)
示例6: test_should_be_true_if_thermostat_fan_is_on
def test_should_be_true_if_thermostat_fan_is_on(self):
with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertTrue(thermostat.fan_on())
示例7: test_should_be_cool_only_for_current_hvac_mode
def test_should_be_cool_only_for_current_hvac_mode(self):
with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertEqual('cool_only', thermostat.current_hvac_mode())
示例8: test_should_be_false_if_response_doesnt_contains_aux_capabilities
def test_should_be_false_if_response_doesnt_contains_aux_capabilities(self):
with open('{}/api_responses/nest.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertFalse('aux' in thermostat.hvac_modes())
示例9: test_current_min_set_point
def test_current_min_set_point(self):
with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertEqual(22.22222222222222, thermostat.current_min_set_point())
示例10: test_objectprefix_should_be_correct
def test_objectprefix_should_be_correct(self):
with open('{}/api_responses/smoke_detector.json'.format(os.path.dirname(__file__))) as smoke_detector_file:
response_dict = json.load(smoke_detector_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SMOKE_DETECTOR])
objectprefix = devices[0].objectprefix
self.assertRegex(objectprefix, "smoke_detectors")
objectprefix = devices[1].objectprefix
self.assertRegex(objectprefix, "smoke_detectors")
示例11: test_should_handle_relay_response
def test_should_handle_relay_response(self):
with open('{}/api_responses/wink_relay_sensor.json'.format(os.path.dirname(__file__))) as relay_file:
response_dict = json.load(relay_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
self.assertEqual(4, len(devices))
self.assertIsInstance(devices[0], WinkHumiditySensor)
self.assertIsInstance(devices[1], WinkTemperatureSensor)
self.assertIsInstance(devices[2], WinkPresenceSensor)
self.assertIsInstance(devices[3], WinkProximitySensor)
示例12: test_device_id_should_be_number
def test_device_id_should_be_number(self):
with open('{}/api_responses/porkfolio.json'.format(os.path.dirname(__file__))) as porkfolio_file:
response_dict = json.load(porkfolio_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.PIGGY_BANK])
device_id = devices[0].device_id()
self.assertRegex(device_id, "^[0-9]{4,6}")
device_id = devices[1].device_id()
self.assertRegex(device_id, "^[0-9]{4,6}")
示例13: test_current_humidifier_mode
def test_current_humidifier_mode(self):
# sensi.json been faked to add in the humidifier_mode field for testing.
with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertEqual('auto', thermostat.current_humidifier_mode())
示例14: test_should_be_true_if_thermostat_has_detected_occupancy
def test_should_be_true_if_thermostat_has_detected_occupancy(self):
# sensi.json been faked to add in the occupied field for testing.
with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
response_dict = json.load(thermostat_file)
devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])
thermostat = devices[0]
""" :type thermostat: pywink.devices.standard.WinkThermostat """
self.assertTrue(thermostat.occupied())
示例15: test_brightness_should_have_correct_value
def test_brightness_should_have_correct_value(self):
with open('{}/api_responses/quirky_spotter.json'.format(os.path.dirname(__file__))) as spotter_file:
response_dict = json.load(spotter_file)
sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
""":type : list of WinkBrightnessSensor"""
brightness_sensor = [sensor for sensor in sensors if sensor.capability() is WinkBrightnessSensor.CAPABILITY][0]
expected_brightness = 1
self.assertEquals(expected_brightness, brightness_sensor.brightness_percentage())