From c23f707dd55f4e8e1ccf8850737d81a2a06b37d9 Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Wed, 29 Dec 2010 15:19:01 +0530 Subject: [PATCH] Fixed tests. Removed theming support --- hyde/ext/templates/jinja.py | 8 +++-- hyde/generator.py | 34 ++++++++++++++++++++ hyde/tests/sites/test_jinja/layout/base.html | 7 ++-- hyde/tests/sites/test_jinja/layout/root.html | 2 +- hyde/tests/test_generator.py | 20 ++++++++++++ hyde/tests/test_initialize.py | 10 +++--- hyde/tests/test_jinja2template.py | 4 ++- hyde/theme.py | 1 - 8 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 hyde/generator.py create mode 100644 hyde/tests/test_generator.py delete mode 100644 hyde/theme.py diff --git a/hyde/ext/templates/jinja.py b/hyde/ext/templates/jinja.py index caeac01..ceb7498 100644 --- a/hyde/ext/templates/jinja.py +++ b/hyde/ext/templates/jinja.py @@ -45,9 +45,11 @@ class Jinja2Template(Template): str(config.media_root_path), str(config.layout_root_path), ]) - self.env = Environment(loader=loader, undefined=LoyalUndefined) - self.env.globals['media_url'] = media_url - self.env.globals['content_url'] = content_url + else: + loader = FileSystemLoader(str(self.sitepath)) + self.env = Environment(loader=loader, undefined=LoyalUndefined) + self.env.globals['media_url'] = media_url + self.env.globals['content_url'] = content_url def render(self, text, context): """ diff --git a/hyde/generator.py b/hyde/generator.py new file mode 100644 index 0000000..bacee29 --- /dev/null +++ b/hyde/generator.py @@ -0,0 +1,34 @@ +""" +The generator class and related utility functions. +""" + +class Generator(object): + """ + Generates output from a node or resource. + """ + + def __init__(self, site): + super(Generator, self).__init__() + self.site = site + + def generate_all(self): + """ + Generates the entire website + """ + pass + + def generate_node(self, node=None): + """ + Generates a single node. If node is non-existent or empty + generates the entire site. + """ + pass + + def generate_resource(self, resource=None): + """ + Generates a single resource. If resource is non-existent or empty + generats the entire website. + """ + pass + + diff --git a/hyde/tests/sites/test_jinja/layout/base.html b/hyde/tests/sites/test_jinja/layout/base.html index afce0f3..62bafb8 100644 --- a/hyde/tests/sites/test_jinja/layout/base.html +++ b/hyde/tests/sites/test_jinja/layout/base.html @@ -5,14 +5,14 @@ {% block starthead %}{% endblock starthead %} - + {% block title %}{{page.meta.title}}{% endblock %} - + {% block favicons %} @@ -49,7 +49,8 @@ {% endblock jquery %} - {% block scripts %} + {% block scripts %}{% endblock scripts %} + {%endblock js %} diff --git a/hyde/tests/sites/test_jinja/layout/root.html b/hyde/tests/sites/test_jinja/layout/root.html index 94ff2a3..00f6151 100644 --- a/hyde/tests/sites/test_jinja/layout/root.html +++ b/hyde/tests/sites/test_jinja/layout/root.html @@ -1 +1 @@ -{% block all %}{% endblock %} \ No newline at end of file +{% block all %}{% endblock all %} \ No newline at end of file diff --git a/hyde/tests/test_generator.py b/hyde/tests/test_generator.py new file mode 100644 index 0000000..a8eb1a9 --- /dev/null +++ b/hyde/tests/test_generator.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# encoding: utf-8 +""" +test_generator.py + +Created by FlowPlayer - Lakshmi Vyas on 2010-12-29. +Copyright (c) 2010 __MyCompanyName__. All rights reserved. +""" + +import sys +import os + + +def main(): + pass + + +if __name__ == '__main__': + main() + diff --git a/hyde/tests/test_initialize.py b/hyde/tests/test_initialize.py index 38ba8d4..c099a19 100644 --- a/hyde/tests/test_initialize.py +++ b/hyde/tests/test_initialize.py @@ -35,26 +35,26 @@ def delete_test_site_at_user(): @with_setup(create_test_site, delete_test_site) def test_ensure_exception_when_sitepath_exists(): e = Engine() - e.run(e.parse(['-s', str(TEST_SITE), 'init'])) + e.run(e.parse(['-s', str(TEST_SITE), 'create'])) @with_setup(create_test_site, delete_test_site) def test_ensure_no_exception_when_sitepath_exists_when_forced(): e = Engine() - e.run(e.parse(['-s', str(TEST_SITE), 'init', '-f'])) + e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) assert True #No Exception @with_setup(create_test_site, delete_test_site) def test_ensure_no_exception_when_sitepath_does_not_exist(): e = Engine() TEST_SITE.delete() - e.run(e.parse(['-s', str(TEST_SITE), 'init', '-f'])) + e.run(e.parse(['-s', str(TEST_SITE), 'create', '-f'])) verify_site_contents(TEST_SITE, Layout.find_layout()) @with_setup(create_test_site_at_user, delete_test_site_at_user) def test_ensure_can_create_site_at_user(): e = Engine() TEST_SITE_AT_USER.delete() - e.run(e.parse(['-s', str(TEST_SITE_AT_USER), 'init', '-f'])) + e.run(e.parse(['-s', str(TEST_SITE_AT_USER), 'create', '-f'])) verify_site_contents(TEST_SITE_AT_USER, Layout.find_layout()) @nottest @@ -76,5 +76,5 @@ def verify_site_contents(site, layout): @with_setup(create_test_site, delete_test_site) def test_ensure_exception_when_layout_is_invalid(): e = Engine() - e.run(e.parse(['-s', str(TEST_SITE), 'init', '-l', 'junk'])) + e.run(e.parse(['-s', str(TEST_SITE), 'create', '-l', 'junk'])) diff --git a/hyde/tests/test_jinja2template.py b/hyde/tests/test_jinja2template.py index c9e8346..1132d0a 100644 --- a/hyde/tests/test_jinja2template.py +++ b/hyde/tests/test_jinja2template.py @@ -58,7 +58,9 @@ def test_render(): t = Jinja2Template(JINJA2.path) t.configure(None) t.env.filters['dateformat'] = dateformat - html = t.render('index.html', context) + source = File(JINJA2.child('index.html')).read_all() + + html = t.render(source, context) from pyquery import PyQuery actual = PyQuery(html) assert actual(".navigation li").length == 30 diff --git a/hyde/theme.py b/hyde/theme.py deleted file mode 100644 index 7c68785..0000000 --- a/hyde/theme.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- \ No newline at end of file