Mercurial > libervia-backend
annotate src/test/test_plugin_misc_groupblog.py @ 1668:a9e86f660653
plugin ip: fixed ip check (XEP-0279) use
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Nov 2015 00:22:23 +0100 |
parents | 7f8af1e69812 |
children | d17772b0fe22 |
rev | line source |
---|---|
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
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 |
1396 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org) |
6 # Copyright (C) 2013, 2014, 2015 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() |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
139 self.plugin = plugin_misc_groupblog.GroupBlog(self.host) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
140 self.plugin._initialise = self._initialise |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
141 self.host.plugins['XEP-0060'] = plugin_xep_0060.XEP_0060(self.host) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
142 self.host.plugins['XEP-0163'] = plugin_xep_0163.XEP_0163(self.host) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
143 self.host.plugins['TEXT-SYNTAXES'] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
144 self.host.plugins['XEP-0277'] = plugin_xep_0277.XEP_0277(self.host) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
145 self.__initialised = False |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
146 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
147 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
148 def _initialise(self, profile_key): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
149 profile = profile_key |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
150 client = self.host.getClient(profile) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
151 if not self.__initialised: |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
152 client.item_access_pubsub = jid.JID(SERVICE) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
153 xep_0060 = self.host.plugins['XEP-0060'] |
1424 | 154 client.pubsub_client = helpers_plugins.FakeSatPubSubClient(self.host, xep_0060) |
155 client.pubsub_client.parent = client | |
156 self.psclient = client.pubsub_client | |
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
157 helpers.FakeSAT.getDiscoItems = self.psclient.service_getDiscoItems |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
158 self.__initialised = True |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
159 return defer.succeed((profile, client)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
160 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
161 def _addItem(self, profile, item, parent_node=None): |
1424 | 162 client = self.host.getClient(profile) |
163 client.pubsub_client._addItem(item, parent_node) | |
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
164 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
165 def test_sendGroupBlog(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
166 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
167 d = self.psclient.items(SERVICE, NODE_ID) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
168 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
173 def test_deleteGroupBlog(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
174 pub_data = (SERVICE, NODE_ID, ITEM_ID_1) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
175 self.host.bridge.expectCall('personalEvent', C.JID_STR[0], |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
176 "MICROBLOG_DELETE", |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
177 {'type': 'main_item', 'id': ITEM_ID_1}, |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
178 C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
179 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
180 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
181 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
|
182 return d.addCallback(self.assertEqual, None) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
183 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
184 def test_updateGroupBlog(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
185 pub_data = (SERVICE, NODE_ID, ITEM_ID_1) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
186 new_text = u"silfu23RFWUP)IWNOEIOEFÖ" |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
187 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
188 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
189 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
194 def test_sendGroupBlogComment(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
195 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
196 d = self.psclient.items(SERVICE, NODE_ID) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
197 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
202 def test_getGroupBlogs(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
203 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
204 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
205 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
|
206 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
|
207 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
208 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
209 def test_getGroupBlogsNoCount(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
210 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
211 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
212 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
|
213 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
|
214 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
215 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
216 def test_getGroupBlogsWithIDs(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
217 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
218 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
219 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
|
220 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
|
221 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
222 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
223 def test_getGroupBlogsWithRSM(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
224 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
229 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
230 def test_getGroupBlogsWithComments(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
231 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
232 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
233 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
|
234 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
|
235 result = ([(ITEM_DATA_1(1), ([COMMENT_DATA_1], |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
236 {'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
|
237 {'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
|
238 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
239 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
240 def test_getGroupBlogsWithComments2(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
241 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
242 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 {'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
|
247 {'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
|
248 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
249 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
250 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
251 def test_getGroupBlogsAtom(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
252 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
253 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
|
254 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
|
255 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
256 def cb(atom): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
257 self.assertIsInstance(atom, unicode) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
258 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
|
259 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
260 return d.addCallback(cb) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
261 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
262 def test_getMassiveGroupBlogs(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
263 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
268 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
269 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
|
270 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
271 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
272 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
273 d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
274 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
275 def test_getMassiveGroupBlogsWithComments(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
276 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
277 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
278 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
|
279 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
|
280 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
|
281 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
282 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
283 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
|
284 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
285 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
286 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
287 d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
288 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
289 def test_getGroupBlogComments(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
290 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
291 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 return d.addCallback(self.assertEqual, result) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
296 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
297 def test_subscribeGroupBlog(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
298 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
299 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
|
300 return d.addCallback(self.assertEqual, None) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
301 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
302 def test_massiveSubscribeGroupBlogs(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
303 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
304 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
|
305 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
306 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
307 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
|
308 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
|
309 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
310 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
311 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
312 return d.addCallback(self.assertEqual, None) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
313 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
314 def test_deleteAllGroupBlogs(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
315 """Delete our main node and associated comments node""" |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
316 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
317 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
|
318 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
319 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
|
320 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
|
321 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
322 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
|
323 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
324 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
325 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
|
326 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
|
327 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
|
328 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
329 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
|
330 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
331 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
332 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
333 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
|
334 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
335 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
336 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
|
337 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
338 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
339 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
|
340 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
341 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
|
342 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
343 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
344 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
|
345 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
346 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
|
347 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
348 return d |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
349 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
350 def test_deleteAllGroupBlogsComments(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
351 """Delete the comments we posted on other node's""" |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
352 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
353 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
|
354 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
355 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
|
356 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
|
357 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
358 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
|
359 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
360 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
361 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
|
362 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
|
363 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
|
364 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
365 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
|
366 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
367 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
368 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
369 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
|
370 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
371 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
372 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
|
373 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
374 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
375 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
|
376 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
377 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
|
378 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
379 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
380 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
|
381 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
382 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
|
383 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
384 return d |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
385 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
386 def test_deleteAllGroupBlogsAndComments(self): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
387 self._initialise(C.PROFILE[0]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
388 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
|
389 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
390 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
|
391 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
|
392 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
393 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
|
394 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
395 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
400 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
|
401 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
402 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
403 def clean(res): |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
404 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
|
405 return res |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
406 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
407 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
|
408 d.addCallback(clean) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
409 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
410 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
|
411 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
412 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
|
413 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
414 |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
415 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
|
416 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
417 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
|
418 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
419 return d |