PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/hyde/tests/ext/test_blockdown.py

http://github.com/hyde/hyde
Python | 46 lines | 33 code | 7 blank | 6 comment | 0 complexity | 8f2689f50d026558ad1f91359a6f7b4e MD5 | raw file
 1# -*- coding: utf-8 -*-
 2"""
 3Use nose
 4`$ pip install nose`
 5`$ nosetests`
 6"""
 7from hyde.generator import Generator
 8from hyde.site import Site
 9
10from fswrap import File
11from pyquery import PyQuery
12
13TEST_SITE = File(__file__).parent.parent.child_folder('_test')
14
15
16class TestBlockdown(object):
17
18    def setUp(self):
19        TEST_SITE.make()
20        TEST_SITE.parent.child_folder(
21                    'sites/test_jinja').copy_contents_to(TEST_SITE)
22
23    def tearDown(self):
24        TEST_SITE.delete()
25
26    def test_can_parse_blockdown(self):
27        s = Site(TEST_SITE)
28        s.config.plugins = ['hyde.ext.plugins.text.BlockdownPlugin']
29        txt ="This template tests to make sure blocks can be replaced with markdownish syntax."
30        templ = """
31{%% extends "base.html" %%}
32=====title========
33%s
34====/title========"""
35
36        content = (templ.strip() % txt).strip()
37        bd = File(TEST_SITE.child('content/blockdown.html'))
38        bd.write(content)
39        gen = Generator(s)
40        gen.generate_resource_at_path(bd.path)
41        res = s.content.resource_from_path(bd.path)
42        target = File(s.config.deploy_root_path.child(res.relative_deploy_path))
43        assert target.exists
44        text = target.read_all()
45        q = PyQuery(text)
46        assert q('title').text().strip() == txt.strip()