Mercurial > libervia-backend
diff sat/test/test_plugin_misc_groupblog.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 378188abe941 |
line wrap: on
line diff
--- a/sat/test/test_plugin_misc_groupblog.py Wed Jun 27 07:51:29 2018 +0200 +++ b/sat/test/test_plugin_misc_groupblog.py Wed Jun 27 20:14:46 2018 +0200 @@ -31,27 +31,32 @@ from twisted.words.protocols.jabber import jid -NS_PUBSUB = 'http://jabber.org/protocol/pubsub' +NS_PUBSUB = "http://jabber.org/protocol/pubsub" DO_NOT_COUNT_COMMENTS = -1 -SERVICE = u'pubsub.example.com' -PUBLISHER = u'test@example.org' -OTHER_PUBLISHER = u'other@xmpp.net' -NODE_ID = u'urn:xmpp:groupblog:{publisher}'.format(publisher=PUBLISHER) -OTHER_NODE_ID = u'urn:xmpp:groupblog:{publisher}'.format(publisher=OTHER_PUBLISHER) -ITEM_ID_1 = u'c745a688-9b02-11e3-a1a3-c0143dd4fe51' -COMMENT_ID_1 = u'd745a688-9b02-11e3-a1a3-c0143dd4fe52' -COMMENT_ID_2 = u'e745a688-9b02-11e3-a1a3-c0143dd4fe53' +SERVICE = u"pubsub.example.com" +PUBLISHER = u"test@example.org" +OTHER_PUBLISHER = u"other@xmpp.net" +NODE_ID = u"urn:xmpp:groupblog:{publisher}".format(publisher=PUBLISHER) +OTHER_NODE_ID = u"urn:xmpp:groupblog:{publisher}".format(publisher=OTHER_PUBLISHER) +ITEM_ID_1 = u"c745a688-9b02-11e3-a1a3-c0143dd4fe51" +COMMENT_ID_1 = u"d745a688-9b02-11e3-a1a3-c0143dd4fe52" +COMMENT_ID_2 = u"e745a688-9b02-11e3-a1a3-c0143dd4fe53" def COMMENTS_NODE_ID(publisher=PUBLISHER): - return u'urn:xmpp:comments:_{id}__urn:xmpp:groupblog:{publisher}'.format(id=ITEM_ID_1, publisher=publisher) + return u"urn:xmpp:comments:_{id}__urn:xmpp:groupblog:{publisher}".format( + id=ITEM_ID_1, publisher=publisher + ) def COMMENTS_NODE_URL(publisher=PUBLISHER): - return u'xmpp:{service}?node={node}'.format(service=SERVICE, id=ITEM_ID_1, - node=COMMENTS_NODE_ID(publisher).replace(':', '%3A').replace('@', '%40')) + return u"xmpp:{service}?node={node}".format( + service=SERVICE, + id=ITEM_ID_1, + node=COMMENTS_NODE_ID(publisher).replace(":", "%3A").replace("@", "%40"), + ) def ITEM(publisher=PUBLISHER): @@ -68,7 +73,12 @@ </author> </entry> </item> - """.format(ns=NS_PUBSUB, id=ITEM_ID_1, publisher=publisher, comments_node_url=COMMENTS_NODE_URL(publisher)) + """.format( + ns=NS_PUBSUB, + id=ITEM_ID_1, + publisher=publisher, + comments_node_url=COMMENTS_NODE_URL(publisher), + ) def COMMENT(id_=COMMENT_ID_1): @@ -84,35 +94,41 @@ </author> </entry> </item> - """.format(ns=NS_PUBSUB, id=id_, publisher=PUBLISHER) + """.format( + ns=NS_PUBSUB, id=id_, publisher=PUBLISHER + ) def ITEM_DATA(id_=ITEM_ID_1, count=0): - res = {'id': ITEM_ID_1, - 'type': 'main_item', - 'content': 'The Uses of This World', - 'author': PUBLISHER, - 'updated': '1071251243.0', - 'published': '1071251243.0', - 'service': SERVICE, - 'comments': COMMENTS_NODE_URL_1, - 'comments_service': SERVICE, - 'comments_node': COMMENTS_NODE_ID_1} + res = { + "id": ITEM_ID_1, + "type": "main_item", + "content": "The Uses of This World", + "author": PUBLISHER, + "updated": "1071251243.0", + "published": "1071251243.0", + "service": SERVICE, + "comments": COMMENTS_NODE_URL_1, + "comments_service": SERVICE, + "comments_node": COMMENTS_NODE_ID_1, + } if count != DO_NOT_COUNT_COMMENTS: - res.update({'comments_count': unicode(count)}) + res.update({"comments_count": unicode(count)}) return res def COMMENT_DATA(id_=COMMENT_ID_1): - return {'id': id_, - 'type': 'comment', - 'content': 'The Uses of This World', - 'author': PUBLISHER, - 'updated': '1071251243.0', - 'published': '1071251243.0', - 'service': SERVICE, - 'node': COMMENTS_NODE_ID_1, - 'verified_publisher': 'false'} + return { + "id": id_, + "type": "comment", + "content": "The Uses of This World", + "author": PUBLISHER, + "updated": "1071251243.0", + "published": "1071251243.0", + "service": SERVICE, + "node": COMMENTS_NODE_ID_1, + "verified_publisher": "false", + } COMMENTS_NODE_ID_1 = COMMENTS_NODE_ID() @@ -128,19 +144,21 @@ def ITEM_DATA_1(count=0): return ITEM_DATA(count=count) + COMMENT_DATA_1 = COMMENT_DATA() COMMENT_DATA_2 = COMMENT_DATA(COMMENT_ID_2) class XEP_groupblogTest(helpers.SatTestCase): - def setUp(self): self.host = helpers.FakeSAT() - self.host.plugins['XEP-0060'] = plugin_xep_0060.XEP_0060(self.host) - self.host.plugins['XEP-0163'] = plugin_xep_0163.XEP_0163(self.host) + self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) + self.host.plugins["XEP-0163"] = plugin_xep_0163.XEP_0163(self.host) reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error - self.host.plugins['TEXT-SYNTAXES'] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) - self.host.plugins['XEP-0277'] = plugin_xep_0277.XEP_0277(self.host) + self.host.plugins["TEXT-SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes( + self.host + ) + self.host.plugins["XEP-0277"] = plugin_xep_0277.XEP_0277(self.host) self.plugin = plugin_misc_groupblog.GroupBlog(self.host) self.plugin._initialise = self._initialise self.__initialised = False @@ -151,8 +169,10 @@ client = self.host.getClient(profile) if not self.__initialised: client.item_access_pubsub = jid.JID(SERVICE) - xep_0060 = self.host.plugins['XEP-0060'] - client.pubsub_client = helpers_plugins.FakeSatPubSubClient(self.host, xep_0060) + xep_0060 = self.host.plugins["XEP-0060"] + client.pubsub_client = helpers_plugins.FakeSatPubSubClient( + self.host, xep_0060 + ) client.pubsub_client.parent = client self.psclient = client.pubsub_client helpers.FakeSAT.getDiscoItems = self.psclient.service_getDiscoItems @@ -167,19 +187,30 @@ self._initialise(C.PROFILE[0]) d = self.psclient.items(SERVICE, NODE_ID) d.addCallback(lambda items: self.assertEqual(len(items), 0)) - d.addCallback(lambda dummy: self.plugin.sendGroupBlog('PUBLIC', [], 'test', {}, C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.sendGroupBlog( + "PUBLIC", [], "test", {}, C.PROFILE[0] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID)) return d.addCallback(lambda items: self.assertEqual(len(items), 1)) def test_deleteGroupBlog(self): pub_data = (SERVICE, NODE_ID, ITEM_ID_1) - self.host.bridge.expectCall('personalEvent', C.JID_STR[0], - "MICROBLOG_DELETE", - {'type': 'main_item', 'id': ITEM_ID_1}, - C.PROFILE[0]) + self.host.bridge.expectCall( + "personalEvent", + C.JID_STR[0], + "MICROBLOG_DELETE", + {"type": "main_item", "id": ITEM_ID_1}, + C.PROFILE[0], + ) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.deleteGroupBlog(pub_data, COMMENTS_NODE_URL_1, profile_key=C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.deleteGroupBlog( + pub_data, COMMENTS_NODE_URL_1, profile_key=C.PROFILE[0] + ) + ) return d.addCallback(self.assertEqual, None) def test_updateGroupBlog(self): @@ -188,71 +219,155 @@ self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.updateGroupBlog(pub_data, COMMENTS_NODE_URL_1, new_text, {}, profile_key=C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.updateGroupBlog( + pub_data, COMMENTS_NODE_URL_1, new_text, {}, profile_key=C.PROFILE[0] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID)) - return d.addCallback(lambda items: self.assertEqual(''.join(items[0].entry.title.children), new_text)) + return d.addCallback( + lambda items: self.assertEqual( + "".join(items[0].entry.title.children), new_text + ) + ) def test_sendGroupBlogComment(self): self._initialise(C.PROFILE[0]) d = self.psclient.items(SERVICE, NODE_ID) d.addCallback(lambda items: self.assertEqual(len(items), 0)) - d.addCallback(lambda dummy: self.plugin.sendGroupBlogComment(COMMENTS_NODE_URL_1, 'test', {}, profile_key=C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.sendGroupBlogComment( + COMMENTS_NODE_URL_1, "test", {}, profile_key=C.PROFILE[0] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) return d.addCallback(lambda items: self.assertEqual(len(items), 1)) def test_getGroupBlogs(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, profile_key=C.PROFILE[0])) - result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, profile_key=C.PROFILE[0]) + ) + result = ( + [ITEM_DATA_1()], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsNoCount(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, count_comments=False, profile_key=C.PROFILE[0])) - result = ([ITEM_DATA_1(DO_NOT_COUNT_COMMENTS)], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogs( + PUBLISHER, count_comments=False, profile_key=C.PROFILE[0] + ) + ) + result = ( + [ITEM_DATA_1(DO_NOT_COUNT_COMMENTS)], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsWithIDs(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, [ITEM_ID_1], profile_key=C.PROFILE[0])) - result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogs( + PUBLISHER, [ITEM_ID_1], profile_key=C.PROFILE[0] + ) + ) + result = ( + [ITEM_DATA_1()], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsWithRSM(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getGroupBlogs(PUBLISHER, rsm_data={'max_': 1}, profile_key=C.PROFILE[0])) - result = ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogs( + PUBLISHER, rsm_data={"max_": 1}, profile_key=C.PROFILE[0] + ) + ) + result = ( + [ITEM_DATA_1()], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsWithComments(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1])) - d.addCallback(lambda dummy: self.plugin.getGroupBlogsWithComments(PUBLISHER, [], profile_key=C.PROFILE[0])) - result = ([(ITEM_DATA_1(1), ([COMMENT_DATA_1], - {'count': '1', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_1}))], - {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1]) + ) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogsWithComments( + PUBLISHER, [], profile_key=C.PROFILE[0] + ) + ) + result = ( + [ + ( + ITEM_DATA_1(1), + ( + [COMMENT_DATA_1], + { + "count": "1", + "index": "0", + "first": COMMENT_ID_1, + "last": COMMENT_ID_1, + }, + ), + ) + ], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsWithComments2(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2])) - d.addCallback(lambda dummy: self.plugin.getGroupBlogsWithComments(PUBLISHER, [], profile_key=C.PROFILE[0])) - result = ([(ITEM_DATA_1(2), ([COMMENT_DATA_1, COMMENT_DATA_2], - {'count': '2', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_2}))], - {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1}) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2] + ) + ) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogsWithComments( + PUBLISHER, [], profile_key=C.PROFILE[0] + ) + ) + result = ( + [ + ( + ITEM_DATA_1(2), + ( + [COMMENT_DATA_1, COMMENT_DATA_2], + { + "count": "2", + "index": "0", + "first": COMMENT_ID_1, + "last": COMMENT_ID_2, + }, + ), + ) + ], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_getGroupBlogsAtom(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getGroupBlogsAtom(PUBLISHER, {'max_': 1}, profile_key=C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogsAtom( + PUBLISHER, {"max_": 1}, profile_key=C.PROFILE[0] + ) + ) def cb(atom): self.assertIsInstance(atom, unicode) @@ -263,11 +378,22 @@ def test_getMassiveGroupBlogs(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.plugin.getMassiveGroupBlogs('JID', [jid.JID(PUBLISHER)], {'max_': 1}, profile_key=C.PROFILE[0])) - result = {PUBLISHER: ([ITEM_DATA_1()], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})} + d.addCallback( + lambda dummy: self.plugin.getMassiveGroupBlogs( + "JID", [jid.JID(PUBLISHER)], {"max_": 1}, profile_key=C.PROFILE[0] + ) + ) + result = { + PUBLISHER: ( + [ITEM_DATA_1()], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) + } def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] return res d.addCallback(clean) @@ -276,12 +402,27 @@ def test_getMassiveGroupBlogsWithComments(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2])) - d.addCallback(lambda dummy: self.plugin.getMassiveGroupBlogs('JID', [jid.JID(PUBLISHER)], {'max_': 1}, profile_key=C.PROFILE[0])) - result = {PUBLISHER: ([ITEM_DATA_1(2)], {'count': '1', 'index': '0', 'first': ITEM_ID_1, 'last': ITEM_ID_1})} + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2] + ) + ) + d.addCallback( + lambda dummy: self.plugin.getMassiveGroupBlogs( + "JID", [jid.JID(PUBLISHER)], {"max_": 1}, profile_key=C.PROFILE[0] + ) + ) + result = { + PUBLISHER: ( + [ITEM_DATA_1(2)], + {"count": "1", "index": "0", "first": ITEM_ID_1, "last": ITEM_ID_1}, + ) + } def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] return res d.addCallback(clean) @@ -290,9 +431,18 @@ def test_getGroupBlogComments(self): self._initialise(C.PROFILE[0]) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1])) - d.addCallback(lambda dummy: self.plugin.getGroupBlogComments(SERVICE, COMMENTS_NODE_ID_1, {'max_': 1}, profile_key=C.PROFILE[0])) - result = ([COMMENT_DATA_1], {'count': '1', 'index': '0', 'first': COMMENT_ID_1, 'last': COMMENT_ID_1}) + d.addCallback( + lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1]) + ) + d.addCallback( + lambda dummy: self.plugin.getGroupBlogComments( + SERVICE, COMMENTS_NODE_ID_1, {"max_": 1}, profile_key=C.PROFILE[0] + ) + ) + result = ( + [COMMENT_DATA_1], + {"count": "1", "index": "0", "first": COMMENT_ID_1, "last": COMMENT_ID_1}, + ) return d.addCallback(self.assertEqual, result) def test_subscribeGroupBlog(self): @@ -302,11 +452,17 @@ def test_massiveSubscribeGroupBlogs(self): self._initialise(C.PROFILE[0]) - d = self.plugin.massiveSubscribeGroupBlogs('JID', [jid.JID(PUBLISHER)], profile_key=C.PROFILE[0]) + d = self.plugin.massiveSubscribeGroupBlogs( + "JID", [jid.JID(PUBLISHER)], profile_key=C.PROFILE[0] + ) def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@subscriptions@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@subscriptions@" + SERVICE + ] return res d.addCallback(clean) @@ -317,21 +473,33 @@ self._initialise(C.PROFILE[0]) self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER)) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) + ) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] return res d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogs(C.PROFILE[0])) @@ -353,21 +521,33 @@ self._initialise(C.PROFILE[0]) self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER)) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) + ) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] return res d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogsComments(C.PROFILE[0])) @@ -388,24 +568,38 @@ self._initialise(C.PROFILE[0]) self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER)) d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1]) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_1, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2])) - d.addCallback(lambda dummy: self.psclient.publish(SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2])) + d.addCallback( + lambda dummy: self.psclient.publish(SERVICE, OTHER_NODE_ID, [ITEM_2]) + ) + d.addCallback( + lambda dummy: self.psclient.publish( + SERVICE, COMMENTS_NODE_ID_2, [COMMENT_1, COMMENT_2] + ) + ) d.addCallback(lambda dummy: self.psclient.items(SERVICE, OTHER_NODE_ID)) d.addCallback(lambda items: self.assertEqual(len(items), 1)) d.addCallback(lambda dummy: self.psclient.items(SERVICE, COMMENTS_NODE_ID_2)) d.addCallback(lambda items: self.assertEqual(len(items), 2)) def clean(res): - del self.host.plugins['XEP-0060'].node_cache[C.PROFILE[0] + '@found@' + SERVICE] + del self.host.plugins["XEP-0060"].node_cache[ + C.PROFILE[0] + "@found@" + SERVICE + ] return res - d.addCallback(lambda dummy: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0])) + d.addCallback( + lambda dummy: self.plugin.deleteAllGroupBlogsAndComments(C.PROFILE[0]) + ) d.addCallback(clean) d.addCallback(lambda dummy: self.psclient.items(SERVICE, NODE_ID))