def test_html_with_replacement(): template = os.path.join('home', 'replacements_import.md') html = engine.get_page(template, {'Title': 'Best Title Ever!', 'link': 'https://training.talkpython.fm'}) text = ''' <h1>This page imports things with data.</h1> <p>We have a paragraph with <a href="https://training.talkpython.fm">a link</a>.</p> <h3>This page had a title set: Best Title Ever!</h3> <p>And more content with the word TITLE.</p> <p>And more inline <strong>content</strong>.</p> '''.strip() assert text == html.strip()
def test_basic_markdown_html(): template = os.path.join('home', 'basic_markdown.md') html = engine.get_page(template, {'a': 1, 'b': 2}) text = ''' <h1>This is the basic title</h1> <p>We have a paragraph with <a href="https://talkpython.fm">a link</a>.</p> <ul> <li>Bullet 1</li> <li>Bullet 2</li> <li>Bullet 3</li> </ul> '''.strip() assert text == html.strip()
def test_html_with_embedded_html(): template = os.path.join('home', 'markdown_with_html.md') html = engine.get_page(template, {}) text = ''' <h1>This is the basic title</h1> <p>We have a paragraph with <a href="https://talkpython.fm">a link</a>.</p> <ul> <li>Bullet 1</li> <li>Bullet 2</li> <li>Bullet 3</li> </ul> <p>We also have an image with some details:</p> <p><a href="http://www.lolcats.com" target="_blank"><img class="img img-responsive" src="http://www.lolcats.com/images/u/11/45/lolcatsdotcom3gp6wm7dw3jihq9t.jpg"></a></p> <p>End of the message.</p> '''.strip() assert text == html.strip()
def test_init_folder_required(): storage.get_storage().clear_settings() with pytest.raises(exceptions.InvalidOperationException): engine.get_page('abc', {})
def test_empty_template(): html = engine.get_page(os.path.join('home', 'empty_markdown.md'), {}) assert html == ''
def test_missing_template_by_folder(): with pytest.raises(exceptions.TemplateNotFoundException): engine.get_page(os.path.join('hiding', 'index.md'), {})
def test_missing_template_by_file(): with pytest.raises(exceptions.TemplateNotFoundException): engine.get_page(os.path.join('home', 'hiding.md'), {})