def test_setup_dirs_args(setup_dir): plist = ['/mock', '/fake', '/mock/app', '/42'] setup_dirs(plist, require_empty=True) assert setup_dir.called setup_dir.assert_any_call('/mock', require_empty=True) setup_dir.assert_any_call('/fake', require_empty=True) setup_dir.assert_any_call('/mock/app', require_empty=True) setup_dir.assert_any_call('/42', require_empty=True)
def test_setup_dirs(setup_dir): plist = ['/mock', '/fake', '/mock/app', '/42'] setup_dirs(plist) assert setup_dir.called setup_dir.assert_any_call('/mock') setup_dir.assert_any_call('/fake') setup_dir.assert_any_call('/mock/app') setup_dir.assert_any_call('/42')
def init_basic(path): ''' Generate a basic CouchApp which contain following files:: /path/ .couchapprc .couchappignore _attachments/ lists/ shows/ updates/ views/ .. versionadded:: 1.1 ''' setup_dir(path, require_empty=True) setup_dirs(os.path.join(path, n) for n in DEFAULT_APP_TREE) save_id(path, '_design/{0}'.format(os.path.split(path)[-1])) localdoc.document(path, create=True)
def test_setup_dirs(setup_dir): plist = ['/mock', '/fake', '/mock/app', '/42'] setup_dirs(plist) assert setup_dir.called
def init_template(path, template='default'): ''' Generates a CouchApp via template :param str path: the app dir :param str template: the templates set name. In following example, it is ``mytmpl``. We expect template dir has following structure:: templates/ app/ functions/ vendor/ mytmpl/ app/ functions/ vendor/ vuejs/ myvue/ app/ functions/ vendor/ vueform/ app/ functions/ vendor/ The ``templates/app`` will be used as default app template. ``templates/functions`` and ``templates/vender`` are default, also. And we can create a dir ``mytmpl`` as custom template set. The template set name can be nested, e.g. ``vuejs/myvue``. ..versionadded:: 1.1 ''' if template in TEMPLATE_TYPES: raise AppError('template name connot be {0}.'.format(TEMPLATE_TYPES)) tmpl_name = os.path.normpath(template) if template else '' # copy ``<template set>/app`` src_dir = find_template_dir(tmpl_name, 'app', raise_error=True) copy_helper(src_dir, path) # construct basic dirs setup_dirs((os.path.join(path, n) for n in DEFAULT_APP_TREE), require_empty=False) # add vendor src_dir = find_template_dir(tmpl_name, tmpl_type='vendor') if src_dir is None: logger.debug('vendor not found in template set "{0}". ' 'fallback to default vendor.'.format(tmpl_name)) src_dir = find_template_dir(tmpl_type='vendor') vendor_dir = os.path.join(path, 'vendor') copy_helper(src_dir, vendor_dir) save_id(path, '_design/{0}'.format(os.path.split(path)[-1])) localdoc.document(path, create=True)