def test_skip_if_exists_for_device(self, post_patch): # this should not throw an error d = Device(skip_if_exists=True) d.provision() # this should throw an error d = Device(skip_if_exists=False) with self.assertRaises(RuntimeError): d.provision()
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)