def test_implicit_overwrite_respected(self, device_overwrite_patch, account_overwrite_patch, post_patch): i = instance_factory(instance='test') # doing this with a Device since raw BroadsoftObject doesn't have an overwrite or build_provision_request method # with default value for implicit overwrite (False) d = Device(mac_address='aabbcc112233', did=6175551212, broadsoftinstance=i) d.provision() self.assertFalse(device_overwrite_patch.called) device_overwrite_patch.called = False # with False for implicit overwrite d = Device(mac_address='aabbcc112233', did=6175551212, implicit_overwrite=False, broadsoftinstance=i) self.assertFalse(device_overwrite_patch.called) d.provision() device_overwrite_patch.called = False # with True for implicit overwrite d = Device(mac_address='aabbcc112233', did=6175551212, implicit_overwrite=True, broadsoftinstance=i) d.provision() self.assertTrue(device_overwrite_patch.called) # doing it again with an Account # with default value for implicit overwrite (False) a = Account(did=6175551212, sip_user_id='*****@*****.**', email='*****@*****.**', broadsoftinstance=i) a.provision() self.assertFalse(account_overwrite_patch.called) account_overwrite_patch.called = False # with False for implicit overwrite a = Account(did=6175551212, sip_user_id='*****@*****.**', email='*****@*****.**', implicit_overwrite=False, broadsoftinstance=i) self.assertFalse(account_overwrite_patch.called) a.provision() account_overwrite_patch.called = False # with True for implicit overwrite a = Account(did=6175551212, sip_user_id='*****@*****.**', email='*****@*****.**', implicit_overwrite=True, broadsoftinstance=i) a.provision() self.assertTrue(account_overwrite_patch.called)
def test_overwrite_when_no_name_and_fetch_returns_result(self, find_device_patch, delete_patch): i = instance_factory(instance='test') d = Device(mac_address='aabbcc112233', did=6175551212, broadsoftinstance=i) d.overwrite() # --- actually, skipping overwrite for Device as we're not expecting to do device management in broadsoft self.assertFalse(delete_patch.called)
def test_find_device_by_mac_passes_kwargs(self, get_list_init_patch, find_device_by_mac_patch): # pass broadsoft instance i = instance_factory(instance='test') d = GroupAccessDeviceGetListRequest.find_device_by_mac( mac_address='aabbcc112233', broadsoftinstance=i) args, kwargs = get_list_init_patch.call_args_list[0] self.assertIn('broadsoftinstance', kwargs) self.assertEqual(kwargs['broadsoftinstance'].__dict__, i.__dict__)
def test_voicemail_inherits_default_surgemail_domain_from_instance(self): test_i = instance_factory(instance='test') prod_i = instance_factory(instance='prod') # default should be prod v = Voicemail() self.assertEqual(prod_i.surgemail_domain, v.surgemail_domain) # explicitly prod v = Voicemail(broadsoftinstance=prod_i) self.assertEqual(prod_i.surgemail_domain, v.surgemail_domain) # explicitly test v = Voicemail(broadsoftinstance=test_i) self.assertEqual(test_i.surgemail_domain, v.surgemail_domain) # can override v = Voicemail(broadsoftinstance=test_i, surgemail_domain='override') self.assertEqual('override', v.surgemail_domain)
def test_overwrite_when_name_provided(self, find_device_patch, delete_patch): i = instance_factory(instance='test') d = Device(name='beaverphone', mac_address='aabbcc112233', did=6175551212, broadsoftinstance=i) d.overwrite() # should not have called find_device_by_mac_and_did() since have a name self.assertFalse(find_device_patch.called) # since a name was inherited, delete() should have been called # self.assertTrue(delete_patch.called) # --- actually, skipping overwrite for Device as we're not expecting to do device management in broadsoft self.assertFalse(delete_patch.called)
def test_set_credentials_passes_broadsoft_instance(self, init_patch, post_patch): i = instance_factory(instance='prod') UserAuthenticationModifyRequest.set_credentials( new_password='******', did=6175551212, sip_user_id='*****@*****.**', broadsoftinstance=i) for call in init_patch.call_args_list: args, kwargs = call self.assertEqual(kwargs['broadsoftinstance'].api_url, i.api_url)
def test_overwrite_when_no_name_and_fetch_returns_no_result(self, find_device_patch, delete_patch): i = instance_factory(instance='test') d = Device(mac_address='aabbcc112233', did=6175551212, broadsoftinstance=i) d.overwrite() # --- actually, skipping overwrite for Device as we're not expecting to do device management in broadsoft self.assertFalse(delete_patch.called) # check the call to find_device_by_mac_and_did() # args, kwargs = find_device_patch.call_args_list[0] # self.assertEqual(d.mac_address, kwargs['mac_address']) # self.assertEqual(d.did, kwargs['did']) # self.assertEqual(i, kwargs['broadsoftinstance']) # device should not have inherited a name at this point self.assertEqual('Generic', d.name) # since a name was not inherited, delete() should not have been called self.assertFalse(delete_patch.called)