예제 #1
0
def delete_line(user):
    try:
        line = line_services.get_by_user_id(user.id)
    except LookupError:
        return
    else:
        line_services.delete(line)
예제 #2
0
def _delete_line(channel, line_id):
    from xivo_dao.data_handler.exception import NotFoundError
    from xivo_dao.data_handler.line import services as line_services

    try:
        line = line_services.get(line_id)
        line_services.delete(line)
    except NotFoundError:
        pass
예제 #3
0
def _delete_line_with_exten_context(channel, exten, context):
    from xivo_dao.data_handler.line import services as line_services

    try:
        line = line_services.get_by_number_context(exten, context)
    except LookupError:
        return

    line_services.delete(line)
예제 #4
0
def _delete_line(channel, line_id):
    from xivo_dao.data_handler.exception import ElementDeletionError
    from xivo_dao.data_handler.exception import ElementNotExistsError
    from xivo_dao.data_handler.line import services as line_services

    try:
        line = line_services.get(line_id)
        line_services.delete(line)
    except (ElementDeletionError, ElementNotExistsError):
        pass
예제 #5
0
def _delete_line_with_exten_context(channel, exten, context):
    from xivo_dao.data_handler.line import services as line_services
    from xivo_dao.data_handler.exception import NotFoundError

    try:
        line = line_services.get_by_number_context(exten, context)
    except NotFoundError:
        return

    line_services.delete(line)
예제 #6
0
    def test_delete(self,
                    line_dao_delete,
                    line_notifier_deleted,
                    device_dao_find,
                    remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'

        line = LineSIP(id=line_id, username=username, secret=secret)

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        line_notifier_deleted.assert_called_once_with(line)
        self.assertEquals(device_dao_find.call_count, 0)
        self.assertEquals(remove_line_from_device.call_count, 0)
예제 #7
0
    def test_delete(self,
                    line_dao_delete,
                    line_notifier_deleted,
                    device_dao_find,
                    remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'

        line = LineSIP(id=line_id, username=username, secret=secret)

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        line_notifier_deleted.assert_called_once_with(line)
        self.assertEquals(device_dao_find.call_count, 0)
        self.assertEquals(remove_line_from_device.call_count, 0)
예제 #8
0
    def test_delete_with_device_not_found(self,
                                          line_dao_delete,
                                          line_notifier_deleted,
                                          device_dao_find,
                                          remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'
        device_id = 15
        device_slot = 1

        line = LineSIP(id=line_id, username=username, secret=secret, device_id=device_id, device_slot=device_slot)
        device_dao_find.return_value = None

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(line.device_id)
        self.assertEquals(remove_line_from_device.call_count, 0)
        line_notifier_deleted.assert_called_once_with(line)
예제 #9
0
    def test_delete_with_device(self,
                                line_dao_delete,
                                line_notifier_deleted,
                                device_dao_find,
                                remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'
        device_id = 15
        device_slot = 1

        line = LineSIP(id=line_id, username=username, secret=secret, device_id=device_id, device_slot=device_slot)
        device = device_dao_find.return_value = Mock()

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(line.device_id)
        remove_line_from_device.assert_called_once_with(device, line)
        line_notifier_deleted.assert_called_once_with(line)
예제 #10
0
    def test_delete_with_device_not_found(self,
                                          line_dao_delete,
                                          line_notifier_deleted,
                                          device_dao_find,
                                          remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'
        device_id = 15
        device_slot = 1

        line = LineSIP(id=line_id, username=username, secret=secret, device_id=device_id, device_slot=device_slot)
        device_dao_find.return_value = None

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(line.device_id)
        self.assertEquals(remove_line_from_device.call_count, 0)
        line_notifier_deleted.assert_called_once_with(line)
예제 #11
0
    def test_delete_with_device(self,
                                line_dao_delete,
                                line_notifier_deleted,
                                device_dao_find,
                                remove_line_from_device):
        line_id = 1
        username = '******'
        secret = 'toto'
        device_id = 15
        device_slot = 1

        line = LineSIP(id=line_id, username=username, secret=secret, device_id=device_id, device_slot=device_slot)
        device = device_dao_find.return_value = Mock()

        line_services.delete(line)

        line_dao_delete.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(line.device_id)
        remove_line_from_device.assert_called_once_with(device, line)
        line_notifier_deleted.assert_called_once_with(line)
예제 #12
0
def delete(lineid):
    line = line_services.get(lineid)
    line_services.delete(line)
    return make_response('', 204)