Mercurial > libervia-backend
annotate libervia/backend/test/test_plugin_misc_groupblog.py @ 4117:d861ad696797
plugin XEP-0045: fix name conflict in errback
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 03 Oct 2023 15:03:53 +0200 |
parents | 4b842c1fb686 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 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 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
1766 | 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 | 23 from .constants import Const as C |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
24 from libervia.backend.test import helpers, helpers_plugins |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
25 from libervia.backend.plugins import plugin_misc_groupblog |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
26 from libervia.backend.plugins import plugin_xep_0060 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
27 from libervia.backend.plugins import plugin_xep_0277 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
28 from libervia.backend.plugins import plugin_xep_0163 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
29 from libervia.backend.plugins import plugin_misc_text_syntaxes |
1269
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 | 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 | 39 SERVICE = "pubsub.example.com" |
40 PUBLISHER = "test@example.org" | |
41 OTHER_PUBLISHER = "other@xmpp.net" | |
42 NODE_ID = "urn:xmpp:groupblog:{publisher}".format(publisher=PUBLISHER) | |
43 OTHER_NODE_ID = "urn:xmpp:groupblog:{publisher}".format(publisher=OTHER_PUBLISHER) | |
44 ITEM_ID_1 = "c745a688-9b02-11e3-a1a3-c0143dd4fe51" | |
45 COMMENT_ID_1 = "d745a688-9b02-11e3-a1a3-c0143dd4fe52" | |
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 | 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 | 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 | 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 | 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 | 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 | 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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
170 client = self.host.get_client(profile) |
1269
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 | 177 client.pubsub_client.parent = client |
178 self.psclient = client.pubsub_client | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
179 helpers.FakeSAT.getDiscoItems = self.psclient.service_get_disco_items |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
183 def _add_item(self, profile, item, parent_node=None): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
184 client = self.host.get_client(profile) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
185 client.pubsub_client._add_item(item, parent_node) |
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
186 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
187 def test_send_group_blog(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
199 def test_delete_group_blog(self): |
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
200 pub_data = (SERVICE, NODE_ID, ITEM_ID_1) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
201 self.host.bridge.expect_call( |
2624
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
217 def test_update_group_blog(self): |
1269
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 | 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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
235 def test_send_group_blog_comment(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
247 def test_get_group_blogs(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
259 def test_get_group_blogs_no_count(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
273 def test_get_group_blogs_with_i_ds(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
287 def test_get_group_blogs_with_rsm(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
301 def test_get_group_blogs_with_comments(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
331 def test_get_group_blogs_with_comments_2(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
364 def test_get_group_blogs_atom(self): |
1269
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 | 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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
379 def test_get_massive_group_blogs(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
403 def test_get_massive_group_blogs_with_comments(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
432 def test_get_group_blog_comments(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
449 def test_subscribe_group_blog(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
454 def test_massive_subscribe_group_blogs(self): |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
472 def test_delete_all_group_blogs(self): |
1269
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]) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
475 self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER)) |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
520 def test_delete_all_group_blogs_comments(self): |
1269
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]) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
523 self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER)) |
1269
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 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
568 def test_delete_all_group_blogs_and_comments(self): |
1269
91e5becc6623
test: add tests for plugin_misc_groupblog
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
569 self._initialise(C.PROFILE[0]) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
570 self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER)) |
1269
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 |