コード例 #1
0
    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)
コード例 #2
0
 def test_fetch_passes_broadsoft_instance(
         self, get_device_patch, from_xml_patch
 ):
     d = Device(broadsoftinstance=broadsoft.requestobjects.lib.BroadsoftRequest.instance_factory())
     d.fetch(target_name='dname')
     call = get_device_patch.call_args_list[0]
     args, kwargs = call
     self.assertIsInstance(kwargs['broadsoftinstance'],
                           broadsoft.requestobjects.lib.BroadsoftRequest.BroadsoftInstance)
コード例 #3
0
    def test_fetch(
            self, get_device_patch, from_xml_patch
    ):
        # d.name set, target_name not
        d = Device(name='beaverphone')
        d.fetch()
        call = get_device_patch.call_args_list[0]
        args, kwargs = call
        self.assertEqual('beaverphone', kwargs['name'])

        # d.name set, target_name set
        d = Device(name='beaverphone')
        d.fetch(target_name='beaverandroid')
        call = get_device_patch.call_args_list[1]
        args, kwargs = call
        self.assertEqual('beaverandroid', kwargs['name'])

        # d.name not set, target_name set
        d = Device()
        d.fetch(target_name='beaverandroid')
        call = get_device_patch.call_args_list[2]
        args, kwargs = call
        self.assertEqual('beaverandroid', kwargs['name'])