def test_remove_line_from_device_no_funckeys(self, device_manager, config_manager, reset_config, reset_to_autoprov): autoprovid = "autoprov1234" config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": {"username": "******"} } } } device_dict = { "ip": "10.60.0.109", "version": "3.2.2.1136", "config": self.device_id, "id": self.device_id } line = LineSIP(device_slot=1) device = Device(id=self.device_id) config_manager().get.return_value = config_dict device_manager().get.return_value = device_dict config_manager().autocreate.return_value = autoprovid try: device_services.remove_line_from_device(device, line) except: self.fail("An exception was raised whereas it should not") reset_config.assert_called_once_with(config_dict) reset_to_autoprov.assert_called_once_with(device)
def test_remove_line_from_device(self, config_manager): config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": {"username": "******"}, "2": {"username": "******"} } } } config_manager().get.return_value = config_dict line = LineSIP(device_slot=2) device = Device(id=self.device_id) expected_arg = { "raw_config": { "protocol": "sip", "sip_lines": { "1": {"username": "******"} } } } device_services.remove_line_from_device(device, line) config_manager().get.assert_called_with(self.device_id) config_manager().update.assert_called_with(expected_arg) self.assertEquals(0, config_manager().autocreate.call_count)
def test_remove_line_from_device_no_funckeys(self, device_manager, config_manager, reset_config, reset_to_autoprov): autoprovid = "autoprov1234" config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": { "username": "******" } } } } device_dict = { "ip": "10.60.0.109", "version": "3.2.2.1136", "config": self.device_id, "id": self.device_id } line = LineSIP(device_slot=1) device = Device(id=self.device_id) config_manager().get.return_value = config_dict device_manager().get.return_value = device_dict config_manager().autocreate.return_value = autoprovid try: device_services.remove_line_from_device(device, line) except: self.fail("An exception was raised whereas it should not") reset_config.assert_called_once_with(config_dict) reset_to_autoprov.assert_called_once_with(device)
def test_remove_line_from_device(self, config_manager): config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": { "username": "******" }, "2": { "username": "******" } } } } config_manager().get.return_value = config_dict line = LineSIP(device_slot=2) device = Device(id=self.device_id) expected_arg = { "raw_config": { "protocol": "sip", "sip_lines": { "1": { "username": "******" } } } } device_services.remove_line_from_device(device, line) config_manager().get.assert_called_with(self.device_id) config_manager().update.assert_called_with(expected_arg) self.assertEquals(0, config_manager().autocreate.call_count)
def test_remove_line_from_device_sccp_autoprov(self, config_manager, reset_to_autoprov): config_manager().get.return_value = { "raw_config": { "protocol": "sccp", } } line = LineSCCP(device_slot=1) device = Device(id=self.device_id) device_services.remove_line_from_device(device, line) reset_to_autoprov.assert_called_with(device)
def test_remove_line_from_device_no_sip_lines(self, config_manager, reset_to_autoprov): config_dict = { "raw_config": { "protocol": "sip", } } config_manager().get.return_value = config_dict line = LineSIP(device_slot=2) device = Device(id=self.device_id) device_services.remove_line_from_device(device, line) config_manager().get.assert_called_with(self.device_id) self.assertEquals(config_manager().update.call_count, 0) self.assertEquals(reset_to_autoprov.update.call_count, 0)
def test_remove_line_from_device_sip_autoprov(self, config_manager, reset_to_autoprov): autoprovid = "autoprov1234" config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": { "username": "******" } }, 'funckeys': { '1': { 'label': 'bob', 'line': 1, 'type': 'blf', 'value': '1001' } } } } config_manager().get.return_value = config_dict config_manager().autocreate.return_value = autoprovid line = LineSIP(device_slot=1) device = Device(id=self.device_id) expected_arg_config = { "raw_config": { "protocol": "sip", } } device_services.remove_line_from_device(device, line) config_manager().get.assert_called_with(self.device_id) reset_to_autoprov.assert_called_with(device) config_manager().update.assert_called_with(expected_arg_config)
def test_remove_line_from_device_sip_autoprov(self, config_manager, reset_to_autoprov): autoprovid = "autoprov1234" config_dict = { "raw_config": { "protocol": "sip", "sip_lines": { "1": {"username": "******"} }, 'funckeys': { '1': { 'label': 'bob', 'line': 1, 'type': 'blf', 'value': '1001' } } } } config_manager().get.return_value = config_dict config_manager().autocreate.return_value = autoprovid line = LineSIP(device_slot=1) device = Device(id=self.device_id) expected_arg_config = { "raw_config": { "protocol": "sip", } } device_services.remove_line_from_device(device, line) config_manager().get.assert_called_with(self.device_id) reset_to_autoprov.assert_called_with(device) config_manager().update.assert_called_with(expected_arg_config)
def remove_line(deviceid, lineid): device = device_services.get(deviceid) line = line_services.get(lineid) device_services.remove_line_from_device(device, line) return make_response('', 204)
def _delete_line_from_device(line): if hasattr(line, 'device_id') and line.device_id: device = device_dao.find(line.device_id) if device: device_services.remove_line_from_device(device, line)