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))
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))
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)
def is_existing_context(context_name): return context_services.find_by_name(context_name)
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])
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')
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])
def validate_context_exists(extension): existing_context = context_services.find_by_name(extension.context) if not existing_context: raise NonexistentParametersError(context=extension.context)
def _check_invalid_context(line): context = context_services.find_by_name(line.context) if not context: raise errors.param_not_found('context', 'Context')