changeset 181:d356f6178623

tests: Add help functions to get and render a simple page.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 04 Jan 2015 14:53:13 -0800
parents ede1a59f481d
children a54d3c0b5f4a
files tests/mockutil.py
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/mockutil.py	Sat Jan 03 23:14:01 2015 -0800
+++ b/tests/mockutil.py	Sun Jan 04 14:53:13 2015 -0800
@@ -4,10 +4,11 @@
 import codecs
 import shutil
 import os.path
-import functools
 import mock
 import yaml
 from piecrust.app import PieCrust, PieCrustConfiguration
+from piecrust.page import Page
+from piecrust.rendering import PageRenderingContext, render_page
 
 
 resources_path = os.path.abspath(
@@ -22,6 +23,18 @@
     return app
 
 
+def get_simple_page(app, rel_path):
+    source = app.getSource('pages')
+    metadata = {'path': os.path.splitext(rel_path)[0]}
+    return Page(source, metadata, rel_path)
+
+
+def render_simple_page(page, uri):
+    ctx = PageRenderingContext(page, uri)
+    rp = render_page(ctx)
+    return rp.content
+
+
 class _MockFsEntry(object):
     def __init__(self, contents):
         self.contents = contents