Пример #1
0
def associate_extension(lineid):
    data = document.parse(request)
    model = formatter.dict_to_model(data, lineid)
    created_model = line_extension_services.associate(model)

    result = formatter.to_api(created_model)
    location = url_for('.associate_extension', lineid=lineid)
    return make_response(result, 201, {'Location': location})
Пример #2
0
def associate_extension(lineid):
    data = document.parse(request)
    model = formatter.dict_to_model(data, lineid)
    created_model = line_extension_services.associate(model)

    result = formatter.to_api(created_model)
    location = url_for('.associate_extension', lineid=lineid)
    return make_response(result, 201, {'Location': location})
Пример #3
0
    def test_associate(self, manager, notifier_associated):
        line_extension = Mock(LineExtension)

        result = line_extension_service.associate(line_extension)
        assert_that(result, equal_to(line_extension))

        manager.associate.assert_called_once_with(line_extension)
        notifier_associated.assert_called_once_with(line_extension)
Пример #4
0
    def test_given_internal_context_then_creates_line_extension(self,
                                                                associate_line_extension,
                                                                get_by_extension_id,
                                                                validate_associate,
                                                                notifier_associated):

        get_by_extension_id.return_value = Mock(Context, type=ContextType.internal)

        line_extension = Mock(LineExtension, line_id=20, extension_id=30)

        result = line_extension_service.associate(line_extension)

        assert_that(result, equal_to(line_extension))
        validate_associate.assert_called_once_with(line_extension)
        associate_line_extension.assert_called_once_with(line_extension)
        notifier_associated.assert_called_once_with(line_extension)
Пример #5
0
    def test_given_incall_context_then_creates_incall(self,
                                                      incall_dao_create,
                                                      find_main_user_line,
                                                      associate_destination,
                                                      get_by_extension_id,
                                                      validate_associate,
                                                      notifier_associated):

        get_by_extension_id.return_value = Mock(Context, type=ContextType.incall)
        user_line = find_main_user_line.return_value = Mock(UserLine, user_id=10, line_id=20)
        created_incall = incall_dao_create.return_value = Mock(Incall, id=40)

        line_extension = Mock(LineExtension, line_id=20, extension_id=30)
        incall = Incall(destination='user',
                        destination_id=user_line.user_id,
                        extension_id=line_extension.extension_id)

        result = line_extension_service.associate(line_extension)

        assert_that(result, equal_to(line_extension))
        validate_associate.assert_called_once_with(line_extension)
        incall_dao_create.assert_called_once_with(incall)
        associate_destination.assert_called_once_with(line_extension.extension_id, 'incall', created_incall.id)
        notifier_associated.assert_called_once_with(line_extension)
Пример #6
0
def associate_extension(line_id, parameters):
    url.check_line_exists(line_id)
    model = formatter.dict_to_model(line_id, parameters)
    created_model = line_extension_services.associate(model)
    return formatter.to_api(created_model)
Пример #7
0
def associate_extension(line_id, parameters):
    model = formatter.dict_to_model(line_id, parameters)
    created_model = line_extension_services.associate(model)
    return formatter.to_api(created_model)