Пример #1
0
def test_init_basic(localdoc, setup_dir, setup_dirs, save_id):
    init_basic('/mock/app')

    assert setup_dir.called
    assert setup_dirs.called
    assert save_id.called
    assert localdoc.document.called
Пример #2
0
def test_init_basic(localdoc, setup_dir, setup_dirs, save_id):
    init_basic('/mock/app')

    assert setup_dir.called
    assert setup_dirs.called
    assert save_id.called
    assert localdoc.document.called
Пример #3
0
def init(conf, *args, **opts):
    if not args:
        dest = os.getcwd()
    else:
        dest = os.path.normpath(os.path.join(os.getcwd(), args[0]))

    if dest is None:
        raise AppError('Unknown dest')

    if opts['empty'] and opts['template']:
        raise AppError('option "empty" cannot use with "template"')

    if util.iscouchapp(dest):
        raise AppError("can't create an app at '{0}'. "
                       "One already exists here.".format(dest))

    if util.findcouchapp(dest):
        raise AppError("can't create an app inside another app '{0}'.".format(
                       util.findcouchapp(dest)))

    # ``couchapp init -e dest``
    if opts['empty']:
        document(dest, create=True)

    # ``couchapp init -t template_name dest``
    elif opts['template']:
        generator.init_template(dest, template=opts['template'])

    # ``couchapp init dest``
    else:
        generator.init_basic(dest)

    logger.info('{0} created.'.format(dest))

    return 0
Пример #4
0
def init(conf, *args, **opts):
    if not args:
        dest = os.getcwd()
    else:
        dest = os.path.normpath(os.path.join(os.getcwd(), args[0]))

    if dest is None:
        raise AppError('Unknown dest')

    if opts['empty'] and opts['template']:
        raise AppError('option "empty" cannot use with "template"')

    if util.iscouchapp(dest):
        raise AppError("can't create an app at '{0}'. "
                       "One already exists here.".format(dest))

    if util.findcouchapp(dest):
        raise AppError("can't create an app inside another app '{0}'.".format(
            util.findcouchapp(dest)))

    # ``couchapp init -e dest``
    if opts['empty']:
        document(dest, create=True)

    # ``couchapp init -t template_name dest``
    elif opts['template']:
        generator.init_template(dest, template=opts['template'])

    # ``couchapp init dest``
    else:
        generator.init_basic(dest)

    logger.info('{0} created.'.format(dest))

    return 0