def test_generate_function_validate_doc(find_template_dir, setup_dir, copy2): generate_function('/app', 'validate_doc_update', 'mock') assert find_template_dir.called setup_dir.assert_called_with('/app', require_empty=False) copy2.assert_called_with('/funcs/validate_doc_update.js', '/app/validate_doc_update.js')
def test_generate_function_view(find_template_dir, setup_dir, copy2): generate_function('/app', 'view', 'mock') assert find_template_dir.called setup_dir.assert_called_with('/app/views/mock', require_empty=True) copy2.assert_any_call('/funcs/view/map.js', '/app/views/mock/map.js') copy2.assert_any_call('/funcs/view/reduce.js', '/app/views/mock/reduce.js')
def generate(ui, path, kind, name, **opts): if kind not in ["app", "view", "list", "show", 'filter', 'function', 'vendor', 'update']: raise AppError("Can't generate %s in your couchapp. generator is unknown" % kind) if kind == "app": generator.generate_app(ui, path, template=opts.get("template"), create=opts.get('create', False)) else: if name is None: raise AppError("Can't generate %s function, name is missing" % kind) generator.generate_function(ui, path, kind, name, opts.get("template"))
def test_generate_function_unkown(find_template_dir, setup_dir, copy2): generate_function('/app', 'magic', 'mock') assert find_template_dir.called assert not setup_dir.called assert not copy2.called
def test_generate_function_spatial(find_template_dir, setup_dir, copy2): generate_function('/app', 'spatial', 'mock') assert find_template_dir.called setup_dir.assert_called_with('/app/spatial', require_empty=False) copy2.assert_called_with('/funcs/spatial.js', '/app/spatial/mock.js')
def test_generate_function_list(find_template_dir, setup_dir, copy2): generate_function('/app', 'list', 'mock') assert find_template_dir.called setup_dir.assert_called_with('/app/lists', require_empty=False) copy2.assert_called_with('/funcs/list.js', '/app/lists/mock.js')