def tests_device_auto_naming(self): """Check the generic Abode device creates a name.""" # Set up device device_text = GLASS.device(status=CONST.STATUS_ONLINE, low_battery=True, no_response=True, tampered=True, out_of_order=True) device_json = json.loads(device_text) device_json['name'] = "" device = abodepy.new_device(device_json, self.abode) generated_name = device.type + ' ' + device.device_id self.assertEqual(device.name, generated_name) device_json['name'] = None device = abodepy.new_device(device_json, self.abode) generated_name = device.type + ' ' + device.device_id self.assertEqual(device.name, generated_name) del device_json['name'] device = abodepy.new_device(device_json, self.abode) generated_name = device.type + ' ' + device.device_id self.assertEqual(device.name, generated_name)
def tests_device_mapping_typetag(self): """Check the generic Abode device maps to none without typetag.""" # Set up device device_text = GLASS.device( status=CONST.STATUS_ONLINE, low_battery=True, no_response=True, tampered=True, out_of_order=True) device_json = json.loads(device_text) with self.assertRaises(abodepy.AbodeException): device_json['type_tag'] = "" abodepy.new_device(device_json, self.abode) with self.assertRaises(abodepy.AbodeException): device_json['type_tag'] = None abodepy.new_device(device_json, self.abode) with self.assertRaises(abodepy.AbodeException): del device_json['type_tag'] abodepy.new_device(device_json, self.abode)