Mercurial > libervia-backend
comparison libervia/backend/test/test_plugin_misc_groupblog.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
153 class XEP_groupblogTest(helpers.SatTestCase): | 153 class XEP_groupblogTest(helpers.SatTestCase): |
154 def setUp(self): | 154 def setUp(self): |
155 self.host = helpers.FakeSAT() | 155 self.host = helpers.FakeSAT() |
156 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) | 156 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) |
157 self.host.plugins["XEP-0163"] = plugin_xep_0163.XEP_0163(self.host) | 157 self.host.plugins["XEP-0163"] = plugin_xep_0163.XEP_0163(self.host) |
158 importlib.reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error | 158 importlib.reload( |
159 plugin_misc_text_syntaxes | |
160 ) # reload the plugin to avoid conflict error | |
159 self.host.plugins["TEXT_SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes( | 161 self.host.plugins["TEXT_SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes( |
160 self.host | 162 self.host |
161 ) | 163 ) |
162 self.host.plugins["XEP-0277"] = plugin_xep_0277.XEP_0277(self.host) | 164 self.host.plugins["XEP-0277"] = plugin_xep_0277.XEP_0277(self.host) |
163 self.plugin = plugin_misc_groupblog.GroupBlog(self.host) | 165 self.plugin = plugin_misc_groupblog.GroupBlog(self.host) |
187 def test_send_group_blog(self): | 189 def test_send_group_blog(self): |
188 self._initialise(C.PROFILE[0]) | 190 self._initialise(C.PROFILE[0]) |
189 d = self.psclient.items(SERVICE, NODE_ID) | 191 d = self.psclient.items(SERVICE, NODE_ID) |
190 d.addCallback(lambda items: self.assertEqual(len(items), 0)) | 192 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
191 d.addCallback( | 193 d.addCallback( |
192 lambda __: self.plugin.sendGroupBlog( | 194 lambda __: self.plugin.sendGroupBlog("PUBLIC", [], "test", {}, C.PROFILE[0]) |
193 "PUBLIC", [], "test", {}, C.PROFILE[0] | |
194 ) | |
195 ) | 195 ) |
196 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) | 196 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) |
197 return d.addCallback(lambda items: self.assertEqual(len(items), 1)) | 197 return d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
198 | 198 |
199 def test_delete_group_blog(self): | 199 def test_delete_group_blog(self): |
482 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) | 482 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) |
483 d.addCallback(lambda items: self.assertEqual(len(items), 1)) | 483 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
484 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) | 484 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) |
485 d.addCallback(lambda items: self.assertEqual(len(items), 2)) | 485 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
486 | 486 |
487 d.addCallback( | 487 d.addCallback(lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) |
488 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) | |
489 ) | |
490 d.addCallback( | 488 d.addCallback( |
491 lambda __: self.psclient.publish( | 489 lambda __: self.psclient.publish( |
492 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] | 490 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] |
493 ) | 491 ) |
494 ) | 492 ) |
530 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) | 528 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) |
531 d.addCallback(lambda items: self.assertEqual(len(items), 1)) | 529 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
532 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) | 530 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) |
533 d.addCallback(lambda items: self.assertEqual(len(items), 2)) | 531 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
534 | 532 |
535 d.addCallback( | 533 d.addCallback(lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) |
536 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) | |
537 ) | |
538 d.addCallback( | 534 d.addCallback( |
539 lambda __: self.psclient.publish( | 535 lambda __: self.psclient.publish( |
540 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] | 536 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] |
541 ) | 537 ) |
542 ) | 538 ) |
577 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) | 573 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) |
578 d.addCallback(lambda items: self.assertEqual(len(items), 1)) | 574 d.addCallback(lambda items: self.assertEqual(len(items), 1)) |
579 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) | 575 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) |
580 d.addCallback(lambda items: self.assertEqual(len(items), 2)) | 576 d.addCallback(lambda items: self.assertEqual(len(items), 2)) |
581 | 577 |
582 d.addCallback( | 578 d.addCallback(lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) |
583 lambda __: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) | |
584 ) | |
585 d.addCallback( | 579 d.addCallback( |
586 lambda __: self.psclient.publish( | 580 lambda __: self.psclient.publish( |
587 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] | 581 SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] |
588 ) | 582 ) |
589 ) | 583 ) |
596 del self.host.plugins["XEP-0060"].node_cache[ | 590 del self.host.plugins["XEP-0060"].node_cache[ |
597 C.PROFILE[0] + "@found@" + SERVICE | 591 C.PROFILE[0] + "@found@" + SERVICE |
598 ] | 592 ] |
599 return res | 593 return res |
600 | 594 |
601 d.addCallback( | 595 d.addCallback(lambda __: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0])) |
602 lambda __: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0]) | |
603 ) | |
604 d.addCallback(clean) | 596 d.addCallback(clean) |
605 | 597 |
606 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) | 598 d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID)) |
607 d.addCallback(lambda items: self.assertEqual(len(items), 0)) | 599 d.addCallback(lambda items: self.assertEqual(len(items), 0)) |
608 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) | 600 d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) |