forked from marteinn/wpparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
37 lines (26 loc) · 1.02 KB
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests"""
import unittest
from wpparser import parse
class ParseTestCase(unittest.TestCase):
def test_parse(self):
result = parse("./blog.wordpress.2014-09-26.xml")
assert len(result["posts"]) is 3
assert result["blog"]["title"] == "Blog"
assert len(result["categories"]) is 1
assert len(result["tags"]) is 1
first_post_tags = result["posts"][0]["tags"]
assert 'nicename' in first_post_tags[0]
assert 'name' in first_post_tags[0]
def test_attachment_metadata(self):
result = parse("./blog.wordpress.2014-09-26.xml")
post = result["posts"][2]
assert "postmeta" in post
assert "attached_file" in post["postmeta"]
assert "attachment_metadata" in post["postmeta"]
assert "_wp_page_template" in post["postmeta"]
attached_file = post["postmeta"]["attached_file"]
assert attached_file == "logo-promo.png"
if __name__ == "__main__":
unittest.main()