def test_txt_reader(): import datetime from catsup.reader import txt_reader post_path = os.path.join(BASE_DIR, "post.txt") post = txt_reader(post_path) assert post.path == post_path assert post.date == post.datetime.strftime("%Y-%m-%d") == "2014-01-04" assert post.datetime == datetime.datetime(2014, 1, 4, 20, 56) assert post.title == "Hello, World!" assert post.content == to_unicode("<br />Hi!<br />I'm happy to use Catsup!<br />中文测试<br />")
def test_txt_reader(): import datetime from catsup.reader import txt_reader post_path = os.path.join(BASE_DIR, "post.txt") post = txt_reader(post_path) assert post.path == post_path assert post.date == "2014-01-04" assert post.datetime == datetime.datetime(2014, 1, 4, 20, 56) assert post.title == "Hello, World!" assert post.content == to_unicode( "<br />Hi!<br />I'm happy to use Catsup!<br />中文测试<br />")
def test_post_permalink(): post_path = os.path.join(BASE_DIR, "post.txt") post = txt_reader(post_path) g.config = catsup.parser.config(os.path.join(BASE_DIR, "config.json")) g.config.permalink.post = "/{title}/" assert post.permalink == "/Hello,-World!/" g.config.permalink.post = "/{filename}/" assert post.permalink == "/post/" g.config.permalink.post = "/{date}/{title}/" assert post.permalink == "/2014-01-04/Hello,-World!/" g.config.permalink.post = "/{datetime.year}/{filename}/" assert post.permalink == "/2014/post/"
def test_read_txt_without_meta(): from catsup.reader import txt_reader post_path = os.path.join(BASE_DIR, "no_meta.txt") post = txt_reader(post_path) assert post.title == "no_meta", post.title