def test_render_template(): post = utils.load_fixture(__file__, 'post.md') base = Content(post) base.app_name = "test" base.template_folder = "markdown/fixtures" base.template = "post.html" expected = utils.load_fixture(__file__, 'post_render.html') actual = base._render_template(title=base.meta['title'], date=base.meta['date'], content=base.post) assert expected == actual
def test_render_template_kwargs(): post = utils.load_fixture(__file__, 'post.md') base = Content(post) base.app_name = "test" base.template_folder = "markdown/fixtures" base.template = "post.html" expected = utils.load_fixture(__file__, 'post_render.html') data = {'title': base.meta['title'], 'date': base.meta['date'], 'content': base.post} actual = base._render_template(**data) assert expected == actual
def test_parse_file_meta(): post = utils.load_fixture(__file__, 'post.md') expected = {'type': 'base', 'title': 'This is a post', 'date': date(2018, 1, 1), 'sfw': False, 'lang': 'go', 'testing': True} actual = Content._extract_meta(post) assert expected == actual
def test_get_invalid_template(): post = utils.load_fixture(__file__, 'post.md') base = Content(post) base.app_name = "test" base.template_folder = "markdown/fixtures" base.template = "nothing.html" with pytest.raises(TemplateNotFound): base._get_template()
def test_get_template(): post = utils.load_fixture(__file__, 'post.md') base = Content(post) base.app_name = "test" base.template_folder = "markdown/fixtures" base.template = "post.html" actual = base._get_template() assert isinstance(actual, Template) assert "post.html" == actual.name
def test_parse_file_content(): post = utils.load_fixture(__file__, 'post.md') expected = "This part of the post contains all the good stuff!" actual = Content._extract_content(post) assert expected == actual