git-svn-id: http://wordpress-library.googlecode.com/svn/trunk@2 c225be49-b319-0410...
[pyWpLib.git] / prove.py
blob5be3e12167e3b1d1224a071292d0ffc3d1591156
2 import wordpresslib
4 import sys, time
5 import datetime
7 wp = wordpresslib.WordPressClient('http://localhost:16081/blog/xmlrpc.php', 'michele', '010779')
8 wp.selectBlog(0)
10 print '========================= newPost ========================='
11 p = wordpresslib.WordPressPost()
12 p.categories = (wp.getCategoryIdFromName('Progetti'),)
13 print p.categories
15 """
16 print '========================= getUserInfo ========================='
17 user = wp.getUserInfo()
18 print 'userid:', user.id
19 print 'firstName:', user.firstName
20 print 'lastName:', user.lastName
21 print 'nickname:', user.nickname
22 print 'email:', user.email
24 print '========================= getUsersBlogs ========================='
25 blogs = wp.getUsersBlogs()
26 for blog in blogs:
27 print 'blogId:', blog.id
28 print 'name:', blog.name
29 print 'url:', blog.url
30 print 'isAdmin:', blog.isAdmin
31 print
33 print '========================= getRecentPosts ========================='
34 for post in wp.getRecentPosts(3):
35 print '%d => %s' % (post.id, post.title)
37 print '========================= getCategoryList ========================='
38 categories = list(wp.getCategoryList())
39 for i in categories:
40 print '%d , %s , %d' % (i.id, i.name, i.isPrimary)
42 print '========================= newPost ========================='
43 p = WordPressPost()
44 p.title = 'Azzo'
45 p.description = 'Testo prova del gatto !!!!'
46 p.categories = (wp.getCategoryIdFromName('Progetti'),)
47 idNewPost = wp.newPost(p, False)
48 if not idNewPost:
49 sys.exit()
50 print idNewPost
52 print '========================= publishPost ========================='
53 print wp.publishPost(idNewPost)
55 print '========================= getPost ========================='
56 post = wp.getPost(idNewPost)
57 print '%d %s %s' % (post.id, post.title, post.date)
59 print '========================= editPost ========================='
60 p = WordPressPost()
61 p.title = 'Azzo (modificato)'
63 now = datetime.datetime.now()
64 p.date = (now + datetime.timedelta(days=1)).timetuple()
65 print p.date
67 p.description = 'Testo prova del gatto !!!!'
68 p.categories = map(wp.getCategoryIdFromName, ('Python', 'Progetti'))
69 wp.editPost(idNewPost, p, True)
71 print '========================= getPost ========================='
72 post = wp.getPost(idNewPost)
73 print '%d %s %s' % (post.id, post.title, post.date)
76 print '========================= getPostCategories ========================='
77 for i in wp.getPostCategories(idNewPost):
78 print '%d , %s , %d' % (i.id, i.name, i.isPrimary)
80 print '========================= getTrackbackPings ========================='
81 print wp.getTrackbackPings(idNewPost)
83 #print '========================= deletePost ========================='
84 print wp.deletePost(idNewPost)
86 print '========================= getLastPost ========================='
87 post = wp.getLastPost()
88 print '%d %s %s' % (post.id, post.title, post.date)
90 """