def load_devices(self): # if there's no XML for the user, fetch entire User. Primary device will be in User record, rest found by # searching for shared call appearances. Since .fetch() calls .load_devices(), will wind up back here. if self.xml is None: self.fetch() # if there is XML for the user... else: # first, any that were directly in xml for ade in self.xml.findall('./command/accessDeviceEndpoint'): d = Device() self.inject_broadsoftinstance(child=d) # the <accessDeviceEndpoint> gives us enough info to actually fetch the device d.bootstrap_access_device_endpoint(ade=ade) d.fetch(target_name=d.name) self.devices.append(d) # now find any shared call appearances sca_xml = UserSharedCallAppearanceGetRequest.get_devices(sip_user_id=self.sip_user_id, broadsoftinstance=self.broadsoftinstance) scas = BroadsoftRequest.convert_results_table(xml=sca_xml) for sca in scas: d = Device() self.inject_broadsoftinstance(child=d) # the shared call appearance listings give us nearly everything about a device, but we run a fetch as well # to get everything d.bootstrap_shared_call_appearance(sca=sca) d.fetch(target_name=d.name) self.devices.append(d)
def test_from_shared_call_appearance(self): row = {'Mac Address': 'aa:bb:cc:dd:ee:ff', 'Device Level': 'Group', 'Allow Termination': 'true', 'Allow Origination': 'true', 'Device Type': 'Polycom-VVX1500', 'Is Active': 'true', 'Port Number': None, 'Line/Port': '*****@*****.**', 'Device Support Visual Device Management': 'false', 'Device Name': 'beavervvx', 'SIP Contact': 'sip:'} d = Device() d.bootstrap_shared_call_appearance(sca=row) self.assertEqual(d.mac_address, row['Mac Address']) self.assertEqual(d.type, row['Device Type']) self.assertEqual(d.line_port, row['Line/Port']) self.assertEqual(d.name, row['Device Name']) self.assertFalse(d.is_primary)