Browse Source

Fixed tests. Removed theming support

main
Lakshmi Vyasarajan 14 years ago
parent
commit
c23f707dd5
8 changed files with 72 additions and 14 deletions
  1. +5
    -3
      hyde/ext/templates/jinja.py
  2. +34
    -0
      hyde/generator.py
  3. +4
    -3
      hyde/tests/sites/test_jinja/layout/base.html
  4. +1
    -1
      hyde/tests/sites/test_jinja/layout/root.html
  5. +20
    -0
      hyde/tests/test_generator.py
  6. +5
    -5
      hyde/tests/test_initialize.py
  7. +3
    -1
      hyde/tests/test_jinja2template.py
  8. +0
    -1
      hyde/theme.py

+ 5
- 3
hyde/ext/templates/jinja.py View File

@@ -45,9 +45,11 @@ class Jinja2Template(Template):
str(config.media_root_path), str(config.media_root_path),
str(config.layout_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): def render(self, text, context):
""" """


+ 34
- 0
hyde/generator.py View File

@@ -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



+ 4
- 3
hyde/tests/sites/test_jinja/layout/base.html View File

@@ -5,14 +5,14 @@
<head> <head>
{% block starthead %}{% endblock starthead %} {% block starthead %}{% endblock starthead %}
<meta charset="{{page.meta.charset|default('utf-8')}}"> <meta charset="{{page.meta.charset|default('utf-8')}}">
<meta http-equiv="X-UA-Compatible" content="{{page.meta.compatibility|default('IE=edge,chrome=1')">
<meta http-equiv="X-UA-Compatible" content="{{page.meta.compatibility|default('IE=edge,chrome=1')}}">


<title>{% block title %}{{page.meta.title}}{% endblock %}</title> <title>{% block title %}{{page.meta.title}}{% endblock %}</title>
<meta name="description" content="{{page.meta.description}}"> <meta name="description" content="{{page.meta.description}}">
<meta name="author" content="{{page.meta.author}}"> <meta name="author" content="{{page.meta.author}}">


<!-- Mobile viewport optimized: j.mp/bplateviewport --> <!-- Mobile viewport optimized: j.mp/bplateviewport -->
<meta name="viewport" content="{{page.meta.viewport|default('width=device-width, initial-scale=1.0')">
<meta name="viewport" content="{{page.meta.viewport|default('width=device-width, initial-scale=1.0')}}">


{% block favicons %} {% block favicons %}
<!-- Place favicon.ico & apple-touch-icon.png in the root of your domain and delete these references --> <!-- Place favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
@@ -49,7 +49,8 @@
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
{% endblock jquery %} {% endblock jquery %}


{% block scripts %}
{% block scripts %}{% endblock scripts %}
{%endblock js %}


</body> </body>
</html> </html>

+ 1
- 1
hyde/tests/sites/test_jinja/layout/root.html View File

@@ -1 +1 @@
{% block all %}{% endblock %}
{% block all %}{% endblock all %}

+ 20
- 0
hyde/tests/test_generator.py View File

@@ -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()


+ 5
- 5
hyde/tests/test_initialize.py View File

@@ -35,26 +35,26 @@ def delete_test_site_at_user():
@with_setup(create_test_site, delete_test_site) @with_setup(create_test_site, delete_test_site)
def test_ensure_exception_when_sitepath_exists(): def test_ensure_exception_when_sitepath_exists():
e = Engine() 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) @with_setup(create_test_site, delete_test_site)
def test_ensure_no_exception_when_sitepath_exists_when_forced(): def test_ensure_no_exception_when_sitepath_exists_when_forced():
e = Engine() 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 assert True #No Exception


@with_setup(create_test_site, delete_test_site) @with_setup(create_test_site, delete_test_site)
def test_ensure_no_exception_when_sitepath_does_not_exist(): def test_ensure_no_exception_when_sitepath_does_not_exist():
e = Engine() e = Engine()
TEST_SITE.delete() 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()) verify_site_contents(TEST_SITE, Layout.find_layout())


@with_setup(create_test_site_at_user, delete_test_site_at_user) @with_setup(create_test_site_at_user, delete_test_site_at_user)
def test_ensure_can_create_site_at_user(): def test_ensure_can_create_site_at_user():
e = Engine() e = Engine()
TEST_SITE_AT_USER.delete() 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()) verify_site_contents(TEST_SITE_AT_USER, Layout.find_layout())


@nottest @nottest
@@ -76,5 +76,5 @@ def verify_site_contents(site, layout):
@with_setup(create_test_site, delete_test_site) @with_setup(create_test_site, delete_test_site)
def test_ensure_exception_when_layout_is_invalid(): def test_ensure_exception_when_layout_is_invalid():
e = Engine() e = Engine()
e.run(e.parse(['-s', str(TEST_SITE), 'init', '-l', 'junk']))
e.run(e.parse(['-s', str(TEST_SITE), 'create', '-l', 'junk']))



+ 3
- 1
hyde/tests/test_jinja2template.py View File

@@ -58,7 +58,9 @@ def test_render():
t = Jinja2Template(JINJA2.path) t = Jinja2Template(JINJA2.path)
t.configure(None) t.configure(None)
t.env.filters['dateformat'] = dateformat 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 from pyquery import PyQuery
actual = PyQuery(html) actual = PyQuery(html)
assert actual(".navigation li").length == 30 assert actual(".navigation li").length == 30


+ 0
- 1
hyde/theme.py View File

@@ -1 +0,0 @@
# -*- coding: utf-8 -*-

Loading…
Cancel
Save