Esempio n. 1
0
    def test_find_by_name_when_context_does_not_exist(self, context_dao_get):
        context_name = 'inexistant_context'
        context_dao_get.return_value = None

        result = context_services.find_by_name(context_name)

        assert_that(result, equal_to(None))
Esempio n. 2
0
    def test_find_by_name(self, context_dao_get):
        context_name = 'my_context'
        context_mock = Mock()
        context_dao_get.return_value = context_mock

        result = context_services.find_by_name(context_name)

        assert_that(result, equal_to(context_mock))
Esempio n. 3
0
def _create_context(channel, name):
    from xivo_dao.data_handler.context import services as context_services
    from xivo_dao.data_handler.context.model import Context, ContextType

    existing_context = context_services.find_by_name(name)
    if not existing_context:
        context = Context(name=name, display_name=name, type=ContextType.internal)
        context_services.create(context)
Esempio n. 4
0
def _create_context(channel, name):
    from xivo_dao.data_handler.context import services as context_services
    from xivo_dao.data_handler.context.model import Context, ContextType

    existing_context = context_services.find_by_name(name)
    if not existing_context:
        context = Context(name=name, display_name=name, type=ContextType.internal)
        context_services.create(context)
Esempio n. 5
0
def is_existing_context(context_name):
    return context_services.find_by_name(context_name)
Esempio n. 6
0
def _check_invalid_context(line):
    context = context_services.find_by_name(line.context)
    if not context:
        raise InvalidParametersError(['context %s does not exist' % line.context])
Esempio n. 7
0
def validate_context_exists(extension):
    existing_context = context_services.find_by_name(extension.context)
    if not existing_context:
        raise errors.param_not_found('context', 'Context')
Esempio n. 8
0
def _check_invalid_context(line):
    context = context_services.find_by_name(line.context)
    if not context:
        raise InvalidParametersError(
            ['context %s does not exist' % line.context])
Esempio n. 9
0
def validate_context_exists(extension):
    existing_context = context_services.find_by_name(extension.context)
    if not existing_context:
        raise NonexistentParametersError(context=extension.context)
Esempio n. 10
0
def _check_invalid_context(line):
    context = context_services.find_by_name(line.context)
    if not context:
        raise errors.param_not_found('context', 'Context')
Esempio n. 11
0
def validate_context_exists(extension):
    existing_context = context_services.find_by_name(extension.context)
    if not existing_context:
        raise NonexistentParametersError(context=extension.context)