def test_markdown_conversion(self): """Should correctly generate HTML from the test markdown file""" db_client = MockDropboxClient() list_str = listsdotmd.load_list_as_string(db_client, 'list1.md') markup = listsdotmd.convert_list_to_html(list_str) _expected_html = u'<h1>List 1</h1>\n\n<ul>\n<li>list item 1</li>\n<li>list item 2</li>\n</ul>\n' self.assertEqual(markup, _expected_html)
def show_list(list_name): """Renders the markdown file corresponding to list_name""" list_path = os.path.join(DROPBOX_LIST_FOLDER, list_name + ".md") try: new_rev = listsdotmd.get_file_rev(db_client, list_path) except ErrorResponse: abort(404) app.logger.error("Couldn't get file rev for: %s", list_name) list_in_redis = r.get(list_name) if list_in_redis: list_in_redis = json.loads(list_in_redis) if not list_in_redis or "rev" not in list_in_redis or (new_rev != list_in_redis["rev"]): try: list_str = listsdotmd.load_list_as_string(db_client, list_path) except ErrorResponse: abort(404) app.logger.error("Couldn't load list from Dropbox: %s", list_name) r.set(list_name, json.dumps({"data": list_str, "rev": new_rev})) else: list_str = list_in_redis["data"] print "List %s loaded from redis" % list_name try: list_html = listsdotmd.convert_list_to_html(list_str) except MarkdownError: abort(404) app.logger.error("Couldn't convert markdown file to HTML: %s", list_name) return render_template("list.html", list_markup=list_html)