Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def test_create(self, context_dao_create, validate_create, notifier_created):
        context_name = 'test'

        context = Context(name=context_name,
                          display_name=context_name,
                          type=ContextType.internal)

        context_dao_create.return_value = context

        result = context_services.create(context)

        validate_create.assert_called_once_with(context)
        context_dao_create.assert_called_once_with(context)
        notifier_created.assert_called_once_with(context)

        assert_that(result, all_of(
            has_property('name', context_name),
            has_property('display_name', context_name),
            has_property('type', ContextType.internal)))