PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/hyde/tests/ext/test_textlinks.py

http://github.com/hyde/hyde
Python | 61 lines | 47 code | 9 blank | 5 comment | 0 complexity | 5316d6fc3696c00f985492d14567d302 MD5 | raw file
 1"""
 2Use nose
 3`$ pip install nose`
 4`$ nosetests`
 5"""
 6from hyde.generator import Generator
 7from hyde.site import Site
 8from urllib import quote
 9
10from fswrap import File
11
12TEST_SITE = File(__file__).parent.parent.child_folder('_test')
13
14
15class TestTextlinks(object):
16
17    def setUp(self):
18        TEST_SITE.make()
19        TEST_SITE.parent.child_folder(
20                    'sites/test_jinja').copy_contents_to(TEST_SITE)
21
22    def tearDown(self):
23        TEST_SITE.delete()
24
25
26
27    def test_textlinks(self):
28        d = {
29            'objects': 'template/variables',
30            'plugins': 'plugins/metadata',
31            'sorter': 'plugins/sorter'
32        }
33        text = u"""
34{%% markdown %%}
35[[!!img/hyde-logo.png]]
36*   [Rich object model][hyde objects] and
37    [overridable hierarchical metadata]([[ %(plugins)s ]]) thats available for use in
38    templates.
39*   Configurable [sorting][], filtering and grouping support.
40
41[hyde objects]: [[ %(objects)s ]]
42[sorting]: [[%(sorter)s]]
43{%% endmarkdown %%}
44"""
45        site = Site(TEST_SITE)
46        site.config.plugins = ['hyde.ext.plugins.text.TextlinksPlugin']
47        site.config.base_url = 'http://example.com/'
48        site.config.media_url = '/media'
49        tlink = File(site.content.source_folder.child('tlink.html'))
50        tlink.write(text % d)
51        print tlink.read_all()
52        gen = Generator(site)
53        gen.generate_all()
54        f = File(site.config.deploy_root_path.child(tlink.name))
55        assert f.exists
56        html = f.read_all()
57        assert html
58        for name, path in d.items():
59
60            assert site.config.base_url +  quote(path) in html
61        assert '/media/img/hyde-logo.png' in html