annotate src/test/test_plugin_misc_groupblog.py @ 2186:9061c7247964

jp (std output): force unicode on simple output
author Goffi <goffi@goffi.org>
date Sun, 12 Mar 2017 23:29:09 +0100
parents 2daf7b4c6756
children 8b37a62336c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1934
2daf7b4c6756 use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents: 1910
diff changeset
1 #!/usr/bin/env python2
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
3
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # SAT: a jabber client
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1425
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1425
diff changeset
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
7
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
11 # (at your option) any later version.
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
12
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
17
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
20
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
21 """ Plugin groupblogs """
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
22
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
23 from constants import Const as C
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
24 from sat.test import helpers, helpers_plugins
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
25 from sat.plugins import plugin_misc_groupblog
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
26 from sat.plugins import plugin_xep_0060
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from sat.plugins import plugin_xep_0277
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from sat.plugins import plugin_xep_0163
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
29 from sat.plugins import plugin_misc_text_syntaxes
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
30 from twisted.internet import defer
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
31 from twisted.words.protocols.jabber import jid
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
32
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
33
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
34 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
35
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
36 DO_NOT_COUNT_COMMENTS = -1
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
37
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
38 SERVICE = u'pubsub.example.com'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
39 PUBLISHER = u'test@example.org'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
40 OTHER_PUBLISHER = u'other@xmpp.net'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
41 NODE_ID = u'urn:xmpp:groupblog:{publisher}'.format(publisher=PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
42 OTHER_NODE_ID = u'urn:xmpp:groupblog:{publisher}'.format(publisher=OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
43 ITEM_ID_1 = u'c745a688-9b02-11e3-a1a3-c0143dd4fe51'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
44 COMMENT_ID_1 = u'd745a688-9b02-11e3-a1a3-c0143dd4fe52'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
45 COMMENT_ID_2 = u'e745a688-9b02-11e3-a1a3-c0143dd4fe53'
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
46
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
47
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
48 def COMMENTS_NODE_ID(publisher=PUBLISHER):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
49 return u'urn:xmpp:comments:_{id}__urn:xmpp:groupblog:{publisher}'.format(id=ITEM_ID_1, publisher=publisher)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
50
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
51
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
52 def COMMENTS_NODE_URL(publisher=PUBLISHER):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
53 return u'xmpp:{service}?node={node}'.format(service=SERVICE, id=ITEM_ID_1,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
54 node=COMMENTS_NODE_ID(publisher).replace(':', '%3A').replace('@', '%40'))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
55
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
56
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
57 def ITEM(publisher=PUBLISHER):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
58 return u"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
59 <item id='{id}' xmlns='{ns}'>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
60 <entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
61 <title type='text'>The Uses of This World</title>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
62 <id>{id}</id>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
63 <updated>2003-12-12T17:47:23Z</updated>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
64 <published>2003-12-12T17:47:23Z</published>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
65 <link href='{comments_node_url}' rel='replies' title='comments'/>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
66 <author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
67 <name>{publisher}</name>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
68 </author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
69 </entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
70 </item>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
71 """.format(ns=NS_PUBSUB, id=ITEM_ID_1, publisher=publisher, comments_node_url=COMMENTS_NODE_URL(publisher))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
72
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
73
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
74 def COMMENT(id_=COMMENT_ID_1):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
75 return u"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
76 <item id='{id}' xmlns='{ns}'>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
77 <entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
78 <title type='text'>The Uses of This World</title>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
79 <id>{id}</id>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
80 <updated>2003-12-12T17:47:23Z</updated>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
81 <published>2003-12-12T17:47:23Z</published>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
82 <author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
83 <name>{publisher}</name>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
84 </author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
85 </entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
86 </item>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
87 """.format(ns=NS_PUBSUB, id=id_, publisher=PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
88
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
89
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
90 def ITEM_DATA(id_=ITEM_ID_1, count=0):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
91 res = {'id': ITEM_ID_1,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
92 'type': 'main_item',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
93 'content': 'The Uses of This World',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
94 'author': PUBLISHER,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
95 'updated': '1071251243.0',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
96 'published': '1071251243.0',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
97 'service': SERVICE,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
98 'comments': COMMENTS_NODE_URL_1,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
99 'comments_service': SERVICE,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
100 'comments_node': COMMENTS_NODE_ID_1}
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
101 if count != DO_NOT_COUNT_COMMENTS:
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
102 res.update({'comments_count': unicode(count)})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
103 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
104
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
105
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
106 def COMMENT_DATA(id_=COMMENT_ID_1):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
107 return {'id': id_,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
108 'type': 'comment',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
109 'content': 'The Uses of This World',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
110 'author': PUBLISHER,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
111 'updated': '1071251243.0',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
112 'published': '1071251243.0',
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
113 'service': SERVICE,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
114 'node': COMMENTS_NODE_ID_1,
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
115 'verified_publisher': 'false'}
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
116
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
117
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
118 COMMENTS_NODE_ID_1 = COMMENTS_NODE_ID()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
119 COMMENTS_NODE_ID_2 = COMMENTS_NODE_ID(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
120 COMMENTS_NODE_URL_1 = COMMENTS_NODE_URL()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
121 COMMENTS_NODE_URL_2 = COMMENTS_NODE_URL(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
122 ITEM_1 = ITEM()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
123 ITEM_2 = ITEM(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
124 COMMENT_1 = COMMENT(COMMENT_ID_1)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
125 COMMENT_2 = COMMENT(COMMENT_ID_2)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
126
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
127
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
128 def ITEM_DATA_1(count=0):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
129 return ITEM_DATA(count=count)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
130
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
131 COMMENT_DATA_1 = COMMENT_DATA()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
132 COMMENT_DATA_2 = COMMENT_DATA(COMMENT_ID_2)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
133
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
134
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
135 class XEP_groupblogTest(helpers.SatTestCase):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
136
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
137 def setUp(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
138 self.host = helpers.FakeSAT()
1910
55440ee00905 test: update some tests
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
139 self.host.plugins['XEP-0060'] = plugin_xep_0060.XEP_0060(self.host)
55440ee00905 test: update some tests
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
140 self.host.plugins['XEP-0163'] = plugin_xep_0163.XEP_0163(self.host)
55440ee00905 test: update some tests
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
141 reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error
55440ee00905 test: update some tests
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
142 self.host.plugins['TEXT-SYNTAXES'] = plugin_misc_text_syntaxes.TextSyntaxes(self.host)
55440ee00905 test: update some tests
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
143 self.host.plugins['XEP-0277'] = plugin_xep_0277.XEP_0277(self.host)
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
144 self.plugin = plugin_misc_groupblog.GroupBlog(self.host)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
145 self.plugin._initialise = self._initialise
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
146 self.__initialised = False
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
147 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
148
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
149 def _initialise(self, profile_key):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
150 profile = profile_key
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
151 client = self.host.getClient(profile)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
152 if not self.__initialised:
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
153 client.item_access_pubsub = jid.JID(SERVICE)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
154 xep_0060 = self.host.plugins['XEP-0060']
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
155 client.pubsub_client = helpers_plugins.FakeSatPubSubClient(self.host, xep_0060)
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
156 client.pubsub_client.parent = client
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
157 self.psclient = client.pubsub_client
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
158 helpers.FakeSAT.getDiscoItems = self.psclient.service_getDiscoItems
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
159 self.__initialised = True
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
160 return defer.succeed((profile, client))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
161
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
162 def _addItem(self, profile, item, parent_node=None):
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
163 client = self.host.getClient(profile)
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
164 client.pubsub_client._addItem(item, parent_node)
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
165
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
166 def test_sendGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
167 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
168 d = self.psclient.items(SERVICE, NODE_ID)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
169 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
170 d.addCallback(lambda dummy: self.plugin.sendGroupBlog('PUBLIC', [], 'test', {}, C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
171 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
172 return d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
173
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
174 def test_deleteGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
175 pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
176 self.host.bridge.expectCall('personalEvent', C.JID_STR[0],
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
177 "MICROBLOG_DELETE",
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
178 {'type': 'main_item', 'id': ITEM_ID_1},
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
179 C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
180
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
181 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
182 d.addCallback(lambda dummy: self.plugin.deleteGroupBlog(pub_data, COMMENTS_NODE_URL_1, profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
183 return d.addCallback(self.assertEqual, None)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
184
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
185 def test_updateGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
186 pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
187 new_text = u"silfu23RFWUP)IWNOEIOEFÖ"
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
188
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
189 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
190 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
191 d.addCallback(lambda dummy: self.plugin.updateGroupBlog(pub_data, COMMENTS_NODE_URL_1, new_text, {}, profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
192 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
193 return d.addCallback(lambda items: self.assertEqual(''.join(items[0].entry.title.children), new_text))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
194
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
195 def test_sendGroupBlogComment(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
196 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
197 d = self.psclient.items(SERVICE, NODE_ID)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
198 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
199 d.addCallback(lambda dummy: self.plugin.sendGroupBlogComment(COMMENTS_NODE_URL_1, 'test', {}, profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
200 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
201 return d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
202
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
203 def test_getGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
204 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
205 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
206 d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
207 result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
208 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
209
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
210 def test_getGroupBlogsNoCount(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
211 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
212 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
213 d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, count_comments=False, profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
214 result = ([ITEM_DATA_1(DO_NOT_COUNT_COMMENTS)], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
215 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
216
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
217 def test_getGroupBlogsWithIDs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
218 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
219 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
220 d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, [ITEM_ID_1], profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
221 result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
222 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
223
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
224 def test_getGroupBlogsWithRSM(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
225 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
226 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
1425
7f8af1e69812 core (tests): fixed bad use of reserved name
Goffi <goffi@goffi.org>
parents: 1424
diff changeset
227 d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, rsm_data={'max_': 1}, profile_key=C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
228 result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
229 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
230
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
231 def test_getGroupBlogsWithComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
232 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
233 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
234 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
235 d.addCallback(lambda dummy: self.plugin.getGroupBlogsWithComments(PUBLISHER, [], profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
236 result = ([(ITEM_DATA_1(1), ([COMMENT_DATA_1],
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
237 {'count': '1', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_1}))],
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
238 {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
239 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
240
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
241 def test_getGroupBlogsWithComments2(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
242 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
243 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
244 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
245 d.addCallback(lambda dummy: self.plugin.getGroupBlogsWithComments(PUBLISHER, [], profile_key=C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
246 result = ([(ITEM_DATA_1(2), ([COMMENT_DATA_1, COMMENT_DATA_2],
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
247 {'count': '2', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_2}))],
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
248 {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
249
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
250 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
251
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
252 def test_getGroupBlogsAtom(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
253 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
254 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
1425
7f8af1e69812 core (tests): fixed bad use of reserved name
Goffi <goffi@goffi.org>
parents: 1424
diff changeset
255 d.addCallback(lambda dummy: self.plugin.getGroupBlogsAtom(PUBLISHER, {'max_': 1}, profile_key=C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
256
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
257 def cb(atom):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
258 self.assertIsInstance(atom, unicode)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
259 self.assertTrue(atom.startswith('<?xml version="1.0" encoding="utf-8"?>'))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
260
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
261 return d.addCallback(cb)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
262
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
263 def test_getMassiveGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
264 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
265 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
1425
7f8af1e69812 core (tests): fixed bad use of reserved name
Goffi <goffi@goffi.org>
parents: 1424
diff changeset
266 d.addCallback(lambda dummy: self.plugin.getMassiveGroupBlogs('JID', [jid.JID(PUBLISHER)], {'max_': 1}, profile_key=C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
267 result = {PUBLISHER: ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})}
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
268
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
269 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
270 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
271 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
272
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
273 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
274 d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
275
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
276 def test_getMassiveGroupBlogsWithComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
277 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
278 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
279 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]))
1425
7f8af1e69812 core (tests): fixed bad use of reserved name
Goffi <goffi@goffi.org>
parents: 1424
diff changeset
280 d.addCallback(lambda dummy: self.plugin.getMassiveGroupBlogs('JID', [jid.JID(PUBLISHER)], {'max_': 1}, profile_key=C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
281 result = {PUBLISHER: ([ITEM_DATA_1(2)], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})}
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
282
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
283 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
284 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
285 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
286
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
287 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
288 d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
289
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
290 def test_getGroupBlogComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
291 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
292 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
293 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1]))
1425
7f8af1e69812 core (tests): fixed bad use of reserved name
Goffi <goffi@goffi.org>
parents: 1424
diff changeset
294 d.addCallback(lambda dummy: self.plugin.getGroupBlogComments(SERVICE, COMMENTS_NODE_ID_1, {'max_': 1}, profile_key=C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
295 result = ([COMMENT_DATA_1], {'count': '1', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_1})
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
296 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
297
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
298 def test_subscribeGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
299 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
300 d = self.plugin.subscribeGroupBlog(PUBLISHER, profile_key=C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
301 return d.addCallback(self.assertEqual, None)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
302
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
303 def test_massiveSubscribeGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
304 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
305 d = self.plugin.massiveSubscribeGroupBlogs('JID', [jid.JID(PUBLISHER)], profile_key=C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
306
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
307 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
308 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
309 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@subscriptions@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
310 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
311
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
312 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
313 return d.addCallback(self.assertEqual, None)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
314
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
315 def test_deleteAllGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
316 """Delete our main node and associated comments node"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
317 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
318 self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
319 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
320 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
321 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
322 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
323 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
324 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
325
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
326 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
327 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
328 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
329 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
330 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
331 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
332
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
333 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
334 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
335 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
336
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
337 d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogs(C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
338 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
339
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
340 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
341 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
342 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
343 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
344
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
345 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
346 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
347 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
348 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
349 return d
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
350
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
351 def test_deleteAllGroupBlogsComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
352 """Delete the comments we posted on other node's"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
353 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
354 self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
355 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
356 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
357 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
358 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
359 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
360 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
361
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
362 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
363 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
364 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
365 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
366 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
367 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
368
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
369 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
370 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
371 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
372
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
373 d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogsComments(C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
374 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
375
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
376 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
377 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
378 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
379 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
380
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
381 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
382 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
383 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
384 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
385 return d
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
386
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
387 def test_deleteAllGroupBlogsAndComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
388 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
389 self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
390 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
391 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
392 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
393 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
394 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
395 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
396
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
397 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
398 d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
399 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
400 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
401 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
402 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
403
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
404 def clean(res):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
405 del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE]
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
406 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
407
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
408 d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0]))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
409 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
410
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
411 d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
412 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
413 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
414 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
415
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
416 d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
417 d.addCallback(lambda items: self.assertEqual(len(items), 1))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
418 d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
419 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
420 return d