forked from maxcutler/python-wordpress-xmlrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pages.py
More file actions
49 lines (37 loc) · 1.63 KB
/
Copy pathtest_pages.py
File metadata and controls
49 lines (37 loc) · 1.63 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
from nose.plugins.attrib import attr
from tests import WordPressTestCase
from wordpress_xmlrpc.methods import pages
from wordpress_xmlrpc.wordpress import WordPressPage
class TestPages(WordPressTestCase):
@attr('pages')
def test_get_page_status_list(self):
status_list = self.client.call(pages.GetPageStatusList())
self.assertTrue(isinstance(status_list, dict))
@attr('pages')
def test_get_page_templates(self):
templates = self.client.call(pages.GetPageTemplates())
self.assertTrue(isinstance(templates, dict))
self.assertTrue('Default' in templates)
@attr('pages')
def test_get_pages(self):
page_list = self.client.call(pages.GetPages(30))
self.assert_list_of_classes(page_list, WordPressPage)
@attr('pages')
def test_page_lifecycle(self):
page = WordPressPage()
page.title = 'Test Page'
page.description = 'This is my test page.'
# create the page
page_id = self.client.call(pages.NewPage(page, True))
self.assertTrue(page_id)
# fetch the newly created page
page2 = self.client.call(pages.GetPage(page_id))
self.assertTrue(isinstance(page2, WordPressPage))
self.assertEqual(str(page2.id), page_id)
# edit the page
page2.description += '<br><b>Updated:</b> This page has been updated.'
response = self.client.call(pages.EditPage(page_id, page2, True))
self.assertTrue(response)
# delete the page
response = self.client.call(pages.DeletePage(page_id))
self.assertTrue(response)