def test_root_pagination(scratch_project, scratch_env): base = scratch_project.tree with open(os.path.join(base, "models", "page.ini"), "w") as f: f.write("[model]\n" "label = {{ this.title }}\n\n" "[children]\n" "model = page\n" "[pagination]\n" "enabled = yes\n" "per_page = 1\n" "[fields.title]\n" "type = string\n" "[fields.body]\n" "type = markdown\n") for name in "a", "b", "c": os.mkdir(os.path.join(base, "content", name)) with open(os.path.join(base, "content", name, "contents.lr"), "w") as f: f.write("_model: page\n" "---\n" "title: Page %s\n" "---\n" "body: Hello World!\n" % name) scratch_pad = Database(scratch_env).new_pad() root = scratch_pad.root assert root.children.count() == 3 root_1 = scratch_pad.resolve_url_path("/") assert root_1.page_num == 1 root_2 = scratch_pad.resolve_url_path("/page/2/") assert root_2.page_num == 2
def test_root_pagination(scratch_project, scratch_env): base = scratch_project.tree with open(os.path.join(base, 'models', 'page.ini'), 'w') as f: f.write( '[model]\n' 'label = {{ this.title }}\n\n' '[children]\n' 'model = page\n' '[pagination]\n' 'enabled = yes\n' 'per_page = 1\n' '[fields.title]\n' 'type = string\n' '[fields.body]\n' 'type = markdown\n' ) for name in 'a', 'b', 'c': os.mkdir(os.path.join(base, 'content', name)) with open(os.path.join(base, 'content', name, 'contents.lr'), 'w') as f: f.write( '_model: page\n' '---\n' 'title: Page %s\n' '---\n' 'body: Hello World!\n' % name ) from lektor.db import Database scratch_pad = Database(scratch_env).new_pad() root = scratch_pad.root assert root.children.count() == 3 root_1 = scratch_pad.resolve_url_path('/') assert root_1.page_num == 1 root_2 = scratch_pad.resolve_url_path('/page/2/') assert root_2.page_num == 2
def test_root_pagination(scratch_project, scratch_env): base = scratch_project.tree with open(os.path.join(base, 'models', 'page.ini'), 'w') as f: f.write( '[model]\n' 'label = {{ this.title }}\n\n' '[children]\n' 'model = page\n' '[pagination]\n' 'enabled = yes\n' 'per_page = 1\n' '[fields.title]\n' 'type = string\n' '[fields.body]\n' 'type = markdown\n' ) for name in 'a', 'b', 'c': os.mkdir(os.path.join(base, 'content', name)) with open(os.path.join(base, 'content', name, 'contents.lr'), 'w') as f: f.write( '_model: page\n' '---\n' 'title: Page %s\n' '---\n' 'body: Hello World!\n' % name ) from lektor.db import Database scratch_pad = Database(scratch_env).new_pad() root = scratch_pad.root assert root.children.count() == 3 root_1 = scratch_pad.resolve_url_path('/') assert root_1.page_num == 1 root_2 = scratch_pad.resolve_url_path('/page/2/') assert root_2.page_num == 2