Esempio n. 1
0
    def test_edit_with_a_device_associated(self,
                                           line_dao_edit,
                                           line_notifier_edited,
                                           device_dao_find,
                                           device_services_rebuild_device_config):
        name = 'line'
        context = 'toto'
        secret = '1234'
        device_id = '2'
        device = Device(id=device_id)
        line = LineSIP(name=name,
                       context=context,
                       username=name,
                       secret=secret,
                       device_id=device_id,
                       device_slot=1)

        device_dao_find.return_value = device

        line_services.edit(line)

        line_dao_edit.assert_called_once_with(line)
        line_notifier_edited.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(device_id)
        device_services_rebuild_device_config.assert_called_once_with(device)
Esempio n. 2
0
    def test_edit_with_a_device_associated(self,
                                           line_dao_edit,
                                           line_notifier_edited,
                                           device_dao_find,
                                           device_services_rebuild_device_config):
        name = 'line'
        context = 'toto'
        secret = '1234'
        device_id = '2'
        device = Device(id=device_id)
        line = LineSIP(name=name,
                       context=context,
                       username=name,
                       secret=secret,
                       device_id=device_id,
                       device_slot=1)

        device_dao_find.return_value = device

        line_services.edit(line)

        line_dao_edit.assert_called_once_with(line)
        line_notifier_edited.assert_called_once_with(line)
        device_dao_find.assert_called_once_with(device_id)
        device_services_rebuild_device_config.assert_called_once_with(device)
Esempio n. 3
0
def _delete_line_associations(channel, line_id):
    from xivo_dao.data_handler.line import services as line_services
    from xivo_dao.data_handler.line_extension import services as line_extension_services
    from xivo_dao.data_handler.user_line import services as user_line_services

    line = line_services.get(line_id)
    line.device_id = None
    line.device_slot = 1
    line_services.edit(line)

    line_extension = line_extension_services.find_by_line_id(line_id)
    if line_extension:
        line_extension_services.dissociate(line_extension)

    user_lines = user_line_services.find_all_by_line_id(line_id)
    secondary_associations = [ul for ul in user_lines if not ul.main_user]
    main_associations = [ul for ul in user_lines if ul.main_user]

    for user_line in secondary_associations + main_associations:
        user_line_services.dissociate(user_line)
Esempio n. 4
0
def _delete_line_associations(channel, line_id):
    from xivo_dao.data_handler.line import services as line_services
    from xivo_dao.data_handler.line_extension import services as line_extension_services
    from xivo_dao.data_handler.user_line import services as user_line_services

    line = line_services.get(line_id)
    line.device_id = None
    line.device_slot = 1
    line_services.edit(line)

    line_extension = line_extension_services.find_by_line_id(line_id)
    if line_extension:
        line_extension_services.dissociate(line_extension)

    user_lines = user_line_services.find_all_by_line_id(line_id)
    secondary_associations = [ul for ul in user_lines if not ul.main_user]
    main_associations = [ul for ul in user_lines if ul.main_user]

    for user_line in secondary_associations + main_associations:
        user_line_services.dissociate(user_line)
Esempio n. 5
0
    def test_edit(self,
                  line_dao_edit,
                  line_notifier_edited,
                  device_dao_find,
                  device_services_rebuild_device_config):
        name = 'line'
        context = 'toto'
        secret = '1234'
        line = LineSIP(name=name,
                       context=context,
                       username=name,
                       secret=secret,
                       device_slot=1)

        line_services.edit(line)

        line_dao_edit.assert_called_once_with(line)
        self.assertEquals(device_dao_find.call_count, 0)
        self.assertEquals(device_services_rebuild_device_config.call_count, 0)
        line_notifier_edited.assert_called_once_with(line)
Esempio n. 6
0
    def test_edit(self,
                  line_dao_edit,
                  line_notifier_edited,
                  device_dao_find,
                  device_services_rebuild_device_config):
        name = 'line'
        context = 'toto'
        secret = '1234'
        line = LineSIP(name=name,
                       context=context,
                       username=name,
                       secret=secret,
                       device_slot=1)

        line_services.edit(line)

        line_dao_edit.assert_called_once_with(line)
        self.assertEquals(device_dao_find.call_count, 0)
        self.assertEquals(device_services_rebuild_device_config.call_count, 0)
        line_notifier_edited.assert_called_once_with(line)
Esempio n. 7
0
def edit(lineid):
    data = document.parse(request)
    line = line_services.get(lineid)
    formatter.update_dict_model(data, line)
    line_services.edit(line)
    return make_response('', 204)