def test_split(): apply_site_dirs("",force_project_path=join(pages_test_root,"web")) config = SiteConfig({}) file_contents = """\ function f() {} """ matter,content = config.split_matter_and_utf8_content(file_contents,{ "Content-Type": "text/javascript" }) assert matter["charset"] == "utf-8" file_contents = """\ --- --- .test {} """ matter,content = config.split_matter_and_utf8_content(file_contents,{ "Content-Type": "text/css" }) assert matter["charset"] == "utf-8" file_contents = """\ --- charset: iso8859-1 --- .test {} """ matter,content = config.split_matter_and_utf8_content(file_contents,{ "Content-Type": "text/css" }) assert matter["charset"] == "iso8859-1" file_contents = """\ --- --- """ matter,content = config.split_matter_and_utf8_content(file_contents,{ "Content-Type": "image/gif", "charset":False }) assert "charset" not in matter
def test_split_matter_content(): apply_site_dirs("",force_project_path=join(pages_test_root,"web")) options, r = server_options_parser.parse_args(args=["--nofork"]) config = SiteConfig(options) header = { "Content-Type": "text/html", } content = None with open(abspath(join(site.PROJECT_DIR,"unicode.md")), "rb") as f: content = f.read() #expander = FileExpander(site.PROJECT_DIR,"unicode.md",config=config) #self.header,self.content,self.fetchContent = self._get_matter_and_content(relpath,header) header2,content2 = config.split_matter_and_utf8_content(content,header) assert type(content2) == unicode assert "test" in header2 assert type(header2["test"]) == unicode
def test_double_dashes(): apply_site_dirs("",force_project_path=join(pages_test_root,"web")) options, r = server_options_parser.parse_args(args=["--nofork"]) config = SiteConfig(options) header = { "Content-Type": "text/html", } content = """--- test: test --- abc---def 123---456 """ expected = """ abc---def 123---456 """ header2,content2 = config.split_matter_and_utf8_content(content,header) #print >>sys.stderr, "from:", content2, "to:", expected, "end" assert content2 == expected