From ddeb792ecedb4629aa7c8bc33c0eaba45b82b755 Mon Sep 17 00:00:00 2001 From: Sunaina Pai Date: Sat, 11 Aug 2018 10:47:51 +0530 Subject: Do not use headers from one post in other posts --- test/test_pages.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/test_pages.py b/test/test_pages.py index 5fe7a4d..9f52fb7 100644 --- a/test/test_pages.py +++ b/test/test_pages.py @@ -18,6 +18,10 @@ class PagesTest(unittest.TestCase): f.write('Foo') with open(os.path.join(self.blog_path, '2018-01-02-bar.txt'), 'w') as f: f.write('Bar') + with open(os.path.join(self.blog_path, 'header-foo.txt'), 'w') as f: + f.write('Foo') + with open(os.path.join(self.blog_path, 'header-bar.txt'), 'w') as f: + f.write('Bar') def tearDown(self): shutil.rmtree(self.blog_path) @@ -61,3 +65,15 @@ class PagesTest(unittest.TestCase): self.assertEqual(len(posts), 2) self.assertEqual(posts[0]['date'], '2018-01-02') self.assertEqual(posts[1]['date'], '2018-01-01') + + def test_content_header_params(self): + # Test that header params from one post is not used in another + # post. + src = os.path.join(self.blog_path, 'header*.txt') + dst = os.path.join(self.site_path, '{{ slug }}.txt') + tpl = '{{ title }}:{{ tag }}:{{ content }}' + makesite.make_pages(src, dst, tpl) + with open(os.path.join(self.site_path, 'header-foo.txt')) as f: + self.assertEqual(f.read(), '{{ title }}:foo:Foo') + with open(os.path.join(self.site_path, 'header-bar.txt')) as f: + self.assertEqual(f.read(), 'bar:{{ tag }}:Bar') -- cgit v1.2.3