annotate sat/test/test_plugin_misc_groupblog.py @ 3995:27e5294649c2

component AP gateway: fix missing argument when calling APOutboxPageRequest
author Goffi <goffi@goffi.org>
date Fri, 10 Feb 2023 17:37:37 +0100
parents be6d91572633
children 524856bd7b19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
1269
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
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
1766
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
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
23 from .constants import Const as C
1269
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
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
32 import importlib
1269
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
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
35 NS_PUBSUB = "http://jabber.org/protocol/pubsub"
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
36
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
37 DO_NOT_COUNT_COMMENTS = -1
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
38
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
39 SERVICE = "pubsub.example.com"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
40 PUBLISHER = "test@example.org"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
41 OTHER_PUBLISHER = "other@xmpp.net"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
42 NODE_ID = "urn:xmpp:groupblog:{publisher}".format(publisher=PUBLISHER)
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
43 OTHER_NODE_ID = "urn:xmpp:groupblog:{publisher}".format(publisher=OTHER_PUBLISHER)
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
44 ITEM_ID_1 = "c745a688-9b02-11e3-a1a3-c0143dd4fe51"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
45 COMMENT_ID_1 = "d745a688-9b02-11e3-a1a3-c0143dd4fe52"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
46 COMMENT_ID_2 = "e745a688-9b02-11e3-a1a3-c0143dd4fe53"
1269
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
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
49 def COMMENTS_NODE_ID(publisher=PUBLISHER):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
50 return "urn:xmpp:comments:_{id}__urn:xmpp:groupblog:{publisher}".format(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
51 id=ITEM_ID_1, publisher=publisher
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
52 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
53
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
54
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
55 def COMMENTS_NODE_URL(publisher=PUBLISHER):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
56 return "xmpp:{service}?node={node}".format(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
57 service=SERVICE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
58 id=ITEM_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
59 node=COMMENTS_NODE_ID(publisher).replace(":", "%3A").replace("@", "%40"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
60 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
61
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
62
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
63 def ITEM(publisher=PUBLISHER):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
64 return """
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
65 <item id='{id}' xmlns='{ns}'>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
66 <entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
67 <title type='text'>The Uses of This World</title>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
68 <id>{id}</id>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
69 <updated>2003-12-12T17:47:23Z</updated>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
70 <published>2003-12-12T17:47:23Z</published>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
71 <link href='{comments_node_url}' rel='replies' title='comments'/>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
72 <author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
73 <name>{publisher}</name>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
74 </author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
75 </entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
76 </item>
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
77 """.format(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
78 ns=NS_PUBSUB,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
79 id=ITEM_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
80 publisher=publisher,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
81 comments_node_url=COMMENTS_NODE_URL(publisher),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
82 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
83
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
84
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
85 def COMMENT(id_=COMMENT_ID_1):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
86 return """
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
87 <item id='{id}' xmlns='{ns}'>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
88 <entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
89 <title type='text'>The Uses of This World</title>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
90 <id>{id}</id>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
91 <updated>2003-12-12T17:47:23Z</updated>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
92 <published>2003-12-12T17:47:23Z</published>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
93 <author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
94 <name>{publisher}</name>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
95 </author>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
96 </entry>
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
97 </item>
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
98 """.format(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
99 ns=NS_PUBSUB, id=id_, publisher=PUBLISHER
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
100 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
101
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
102
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
103 def ITEM_DATA(id_=ITEM_ID_1, count=0):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
104 res = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
105 "id": ITEM_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
106 "type": "main_item",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
107 "content": "The Uses of This World",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
108 "author": PUBLISHER,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
109 "updated": "1071251243.0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
110 "published": "1071251243.0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
111 "service": SERVICE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
112 "comments": COMMENTS_NODE_URL_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
113 "comments_service": SERVICE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
114 "comments_node": COMMENTS_NODE_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
115 }
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
116 if count != DO_NOT_COUNT_COMMENTS:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
117 res.update({"comments_count": str(count)})
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
118 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
119
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
120
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
121 def COMMENT_DATA(id_=COMMENT_ID_1):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
122 return {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
123 "id": id_,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
124 "type": "comment",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
125 "content": "The Uses of This World",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
126 "author": PUBLISHER,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
127 "updated": "1071251243.0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
128 "published": "1071251243.0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
129 "service": SERVICE,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
130 "node": COMMENTS_NODE_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
131 "verified_publisher": "false",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
132 }
1269
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 COMMENTS_NODE_ID_1 = COMMENTS_NODE_ID()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
136 COMMENTS_NODE_ID_2 = COMMENTS_NODE_ID(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
137 COMMENTS_NODE_URL_1 = COMMENTS_NODE_URL()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
138 COMMENTS_NODE_URL_2 = COMMENTS_NODE_URL(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
139 ITEM_1 = ITEM()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
140 ITEM_2 = ITEM(OTHER_PUBLISHER)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
141 COMMENT_1 = COMMENT(COMMENT_ID_1)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
142 COMMENT_2 = COMMENT(COMMENT_ID_2)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
143
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
144
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
145 def ITEM_DATA_1(count=0):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
146 return ITEM_DATA(count=count)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
147
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
148
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
149 COMMENT_DATA_1 = COMMENT_DATA()
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
150 COMMENT_DATA_2 = COMMENT_DATA(COMMENT_ID_2)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
151
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
152
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
153 class XEP_groupblogTest(helpers.SatTestCase):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
154 def setUp(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
155 self.host = helpers.FakeSAT()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
156 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
157 self.host.plugins["XEP-0163"] = plugin_xep_0163.XEP_0163(self.host)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
158 importlib.reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error
2780
85d3240a400f plugin text syntaxes: changed import name to TEXT_SYNTAX (better with underscore for autocompletion)
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
159 self.host.plugins["TEXT_SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
160 self.host
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
161 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
162 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
163 self.plugin = plugin_misc_groupblog.GroupBlog(self.host)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
164 self.plugin._initialise = self._initialise
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
165 self.__initialised = False
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
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
168 def _initialise(self, profile_key):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
169 profile = profile_key
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
170 client = self.host.getClient(profile)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
171 if not self.__initialised:
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
172 client.item_access_pubsub = jid.JID(SERVICE)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
173 xep_0060 = self.host.plugins["XEP-0060"]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
174 client.pubsub_client = helpers_plugins.FakeSatPubSubClient(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
175 self.host, xep_0060
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
176 )
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
177 client.pubsub_client.parent = client
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
178 self.psclient = client.pubsub_client
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
179 helpers.FakeSAT.getDiscoItems = self.psclient.service_getDiscoItems
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
180 self.__initialised = True
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
181 return defer.succeed((profile, client))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
182
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
183 def _addItem(self, profile, item, parent_node=None):
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
184 client = self.host.getClient(profile)
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
185 client.pubsub_client._addItem(item, parent_node)
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
186
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
187 def test_sendGroupBlog(self):
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.items(SERVICE, NODE_ID)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
190 d.addCallback(lambda items: self.assertEqual(len(items), 0))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
191 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
192 lambda __: self.plugin.sendGroupBlog(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
193 "PUBLIC", [], "test", {}, C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
194 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
195 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
196 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
197 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
198
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
199 def test_deleteGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
200 pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
201 self.host.bridge.expectCall(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
202 "personalEvent",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
203 C.JID_STR[0],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
204 "MICROBLOG_DELETE",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
205 {"type": "main_item", "id": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
206 C.PROFILE[0],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
207 )
1269
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 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
210 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
211 lambda __: self.plugin.deleteGroupBlog(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
212 pub_data, COMMENTS_NODE_URL_1, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
213 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
214 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
215 return d.addCallback(self.assertEqual, None)
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_updateGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
218 pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
219 new_text = "silfu23RFWUP)IWNOEIOEFÖ"
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
220
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
221 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
222 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
223 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
224 lambda __: self.plugin.updateGroupBlog(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
225 pub_data, COMMENTS_NODE_URL_1, new_text, {}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
226 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
227 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
228 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
229 return d.addCallback(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
230 lambda items: self.assertEqual(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
231 "".join(items[0].entry.title.children), new_text
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
232 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
233 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
234
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
235 def test_sendGroupBlogComment(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
236 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
237 d = self.psclient.items(SERVICE, NODE_ID)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
238 d.addCallback(lambda items: self.assertEqual(len(items), 0))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
239 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
240 lambda __: self.plugin.sendGroupBlogComment(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
241 COMMENTS_NODE_URL_1, "test", {}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
242 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
243 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
244 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
245 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
246
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
247 def test_getGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
248 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
249 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
250 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
251 lambda __: self.plugin.getGroupBlogs(PUBLISHER, profile_key=C.PROFILE[0])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
252 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
253 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
254 [ITEM_DATA_1()],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
255 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
256 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
257 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
258
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
259 def test_getGroupBlogsNoCount(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
260 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
261 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
262 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
263 lambda __: self.plugin.getGroupBlogs(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
264 PUBLISHER, count_comments=False, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
265 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
266 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
267 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
268 [ITEM_DATA_1(DO_NOT_COUNT_COMMENTS)],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
269 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
270 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
271 return d.addCallback(self.assertEqual, result)
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 def test_getGroupBlogsWithIDs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
274 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
275 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
276 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
277 lambda __: self.plugin.getGroupBlogs(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
278 PUBLISHER, [ITEM_ID_1], profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
279 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
280 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
281 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
282 [ITEM_DATA_1()],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
283 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
284 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
285 return d.addCallback(self.assertEqual, result)
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 def test_getGroupBlogsWithRSM(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
288 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
289 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
290 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
291 lambda __: self.plugin.getGroupBlogs(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
292 PUBLISHER, rsm_data={"max_": 1}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
293 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
294 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
295 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
296 [ITEM_DATA_1()],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
297 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
298 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
299 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
300
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
301 def test_getGroupBlogsWithComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
302 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
303 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
304 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
305 lambda __: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
306 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
307 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
308 lambda __: self.plugin.getGroupBlogsWithComments(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
309 PUBLISHER, [], profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
310 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
311 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
312 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
313 [
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
314 (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
315 ITEM_DATA_1(1),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
316 (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
317 [COMMENT_DATA_1],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
318 {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
319 "count": "1",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
320 "index": "0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
321 "first": COMMENT_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
322 "last": COMMENT_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
323 },
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
324 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
325 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
326 ],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
327 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
328 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
329 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
330
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
331 def test_getGroupBlogsWithComments2(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
332 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
333 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
334 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
335 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
336 SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
337 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
338 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
339 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
340 lambda __: self.plugin.getGroupBlogsWithComments(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
341 PUBLISHER, [], profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
342 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
343 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
344 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
345 [
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
346 (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
347 ITEM_DATA_1(2),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
348 (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
349 [COMMENT_DATA_1, COMMENT_DATA_2],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
350 {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
351 "count": "2",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
352 "index": "0",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
353 "first": COMMENT_ID_1,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
354 "last": COMMENT_ID_2,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
355 },
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
356 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
357 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
358 ],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
359 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
360 )
1269
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 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
363
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
364 def test_getGroupBlogsAtom(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
365 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
366 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
367 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
368 lambda __: self.plugin.getGroupBlogsAtom(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
369 PUBLISHER, {"max_": 1}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
370 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
371 )
1269
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 def cb(atom):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2780
diff changeset
374 self.assertIsInstance(atom, str)
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
375 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
376
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
377 return d.addCallback(cb)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
378
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
379 def test_getMassiveGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
380 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
381 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
382 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
383 lambda __: self.plugin.getMassiveGroupBlogs(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
384 "JID", [jid.JID(PUBLISHER)], {"max_": 1}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
385 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
386 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
387 result = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
388 PUBLISHER: (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
389 [ITEM_DATA_1()],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
390 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
391 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
392 }
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
393
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
394 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
395 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
396 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
397 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
398 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
399
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
400 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
401 d.addCallback(self.assertEqual, result)
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 test_getMassiveGroupBlogsWithComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
404 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
405 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
406 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
407 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
408 SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
409 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
410 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
411 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
412 lambda __: self.plugin.getMassiveGroupBlogs(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
413 "JID", [jid.JID(PUBLISHER)], {"max_": 1}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
414 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
415 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
416 result = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
417 PUBLISHER: (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
418 [ITEM_DATA_1(2)],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
419 {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
420 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
421 }
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
422
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
423 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
424 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
425 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
426 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
427 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
428
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
429 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
430 d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
431
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
432 def test_getGroupBlogComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
433 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
434 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
435 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
436 lambda __: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
437 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
438 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
439 lambda __: self.plugin.getGroupBlogComments(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
440 SERVICE, COMMENTS_NODE_ID_1, {"max_": 1}, profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
441 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
442 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
443 result = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
444 [COMMENT_DATA_1],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
445 {"count": "1", "index": "0", "first": COMMENT_ID_1, "last": COMMENT_ID_1},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
446 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
447 return d.addCallback(self.assertEqual, result)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
448
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
449 def test_subscribeGroupBlog(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
450 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
451 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
452 return d.addCallback(self.assertEqual, None)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
453
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
454 def test_massiveSubscribeGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
455 self._initialise(C.PROFILE[0])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
456 d = self.plugin.massiveSubscribeGroupBlogs(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
457 "JID", [jid.JID(PUBLISHER)], profile_key=C.PROFILE[0]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
458 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
459
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
460 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
461 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
462 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
463 ]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
464 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
465 C.PROFILE[0] + "@subscriptions@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
466 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
467 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
468
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
469 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
470 return d.addCallback(self.assertEqual, None)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
471
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
472 def test_deleteAllGroupBlogs(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
473 """Delete our main node and associated comments node"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
474 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
475 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
476 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
477 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
478 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
479 SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
480 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
481 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
482 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
483 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
484 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
485 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
486
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
487 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
488 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
489 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
490 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
491 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
492 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
493 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
494 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
495 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
496 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
497 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
498 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
499
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
500 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
501 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
502 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
503 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
504 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
505
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
506 d.addCallback(lambda __: self.plugin.deleteAllGroupBlogs(C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
507 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
508
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
509 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
510 d.addCallback(lambda items: self.assertEqual(len(items), 0))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
511 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
512 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
513
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
514 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
515 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
516 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
517 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
518 return d
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
519
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
520 def test_deleteAllGroupBlogsComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
521 """Delete the comments we posted on other node's"""
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
522 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
523 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
524 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
525 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
526 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
527 SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
528 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
529 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
530 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
531 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
532 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
533 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
534
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
535 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
536 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
537 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
538 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
539 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
540 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
541 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
542 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
543 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
544 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
545 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
546 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
547
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
548 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
549 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
550 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
551 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
552 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
553
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
554 d.addCallback(lambda __: self.plugin.deleteAllGroupBlogsComments(C.PROFILE[0]))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
555 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
556
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
557 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
558 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
559 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
560 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
561
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
562 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
563 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
564 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
565 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
566 return d
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
567
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
568 def test_deleteAllGroupBlogsAndComments(self):
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
569 self._initialise(C.PROFILE[0])
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
570 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
571 d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
572 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
573 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
574 SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
575 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
576 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
577 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
578 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
579 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
580 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
581
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
582 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
583 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
584 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
585 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
586 lambda __: self.psclient.publish(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
587 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
588 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
589 )
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
590 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
591 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
592 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
593 d.addCallback(lambda items: self.assertEqual(len(items), 2))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
594
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
595 def clean(res):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
596 del self.host.plugins["XEP-0060"].node_cache[
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
597 C.PROFILE[0] + "@found@" + SERVICE
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
598 ]
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
599 return res
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
600
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
601 d.addCallback(
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
602 lambda __: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0])
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
603 )
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
604 d.addCallback(clean)
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
605
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
606 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
607 d.addCallback(lambda items: self.assertEqual(len(items), 0))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
608 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
609 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
610
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
611 d.addCallback(lambda __: self.psclient.items(SERVICE, OTHER_NODE_ID))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
612 d.addCallback(lambda items: self.assertEqual(len(items), 1))
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
613 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2))
1269
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
614 d.addCallback(lambda items: self.assertEqual(len(items), 0))
91e5becc6623 test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff changeset
615 return d