diff sat/test/helpers_plugins.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 003b8b4b56a7
line wrap: on
line diff
--- a/sat/test/helpers_plugins.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/test/helpers_plugins.py	Wed Jun 27 20:14:46 2018 +0200
@@ -57,8 +57,12 @@
             if other_profile == profile:
                 continue
             try:
-                other_room = self.plugin_parent.clients[other_profile].joined_rooms[room_jid]
-                roster.setdefault(other_room.nick, User(other_room.nick, C.PROFILE_DICT[other_profile]))
+                other_room = self.plugin_parent.clients[other_profile].joined_rooms[
+                    room_jid
+                ]
+                roster.setdefault(
+                    other_room.nick, User(other_room.nick, C.PROFILE_DICT[other_profile])
+                )
                 for other_nick in other_room.roster:
                     roster.setdefault(other_nick, other_room.roster[other_nick])
             except (AttributeError, KeyError):
@@ -80,8 +84,12 @@
             if other_profile == profile:
                 continue
             try:
-                other_room = self.plugin_parent.clients[other_profile].joined_rooms[room_jid]
-                other_room.roster.setdefault(room.nick, User(room.nick, C.PROFILE_DICT[profile]))
+                other_room = self.plugin_parent.clients[other_profile].joined_rooms[
+                    room_jid
+                ]
+                other_room.roster.setdefault(
+                    room.nick, User(room.nick, C.PROFILE_DICT[profile])
+                )
             except (AttributeError, KeyError):
                 pass
 
@@ -101,7 +109,9 @@
             if other_profile == profile:
                 continue
             try:
-                other_room = self.plugin_parent.clients[other_profile].joined_rooms[roomJID]
+                other_room = self.plugin_parent.clients[other_profile].joined_rooms[
+                    roomJID
+                ]
                 del other_room.roster[room.nick]
             except (AttributeError, KeyError):
                 pass
@@ -110,14 +120,13 @@
 
 
 class FakeXEP_0045(plugin_xep_0045.XEP_0045):
-
     def __init__(self, host):
         self.host = host
         self.clients = {}
         for profile in C.PROFILE:
             self.clients[profile] = FakeMUCClient(self)
 
-    def join(self, room_jid, nick, options={}, profile_key='@DEFAULT@'):
+    def join(self, room_jid, nick, options={}, profile_key="@DEFAULT@"):
         """
         @param roomJID: the room JID
         @param nick: nick to be used in the room
@@ -140,7 +149,7 @@
         self.join(muc_jid, nick, profile_key=profile)
         return self.getNick(muc_index, user_index)
 
-    def leave(self, room_jid, profile_key='@DEFAULT@'):
+    def leave(self, room_jid, profile_key="@DEFAULT@"):
         """
         @param roomJID: the room JID
         @param profile_key: the profile of the user leaving the room
@@ -174,7 +183,7 @@
         try:
             return self.getRoomNick(C.MUC[muc_index], C.PROFILE[user_index])
         except (KeyError, AttributeError):
-            return ''
+            return ""
 
     def getNickOfUser(self, muc_index, user_index, profile_index, secure=True):
         try:
@@ -185,11 +194,10 @@
 
 
 class FakeXEP_0249(object):
-
     def __init__(self, host):
         self.host = host
 
-    def invite(self, target, room, options={}, profile_key='@DEFAULT@'):
+    def invite(self, target, room, options={}, profile_key="@DEFAULT@"):
         """
         Invite a user to a room. To accept the invitation from a test,
         just call FakeXEP_0045.joinRoom (no need to have a dedicated method).
@@ -202,15 +210,13 @@
 
 
 class FakeSatPubSubClient(object):
-
     def __init__(self, host, parent_plugin):
         self.host = host
         self.parent_plugin = parent_plugin
         self.__items = OrderedDict()
         self.__rsm_responses = {}
 
-    def createNode(self, service, nodeIdentifier=None, options=None,
-                   sender=None):
+    def createNode(self, service, nodeIdentifier=None, options=None, sender=None):
         return defer.succeed(None)
 
     def deleteNode(self, service, nodeIdentifier, sender=None):
@@ -220,12 +226,17 @@
             pass
         return defer.succeed(None)
 
-    def subscribe(self, service, nodeIdentifier, subscriber,
-                  options=None, sender=None):
+    def subscribe(self, service, nodeIdentifier, subscriber, options=None, sender=None):
         return defer.succeed(None)
 
-    def unsubscribe(self, service, nodeIdentifier, subscriber,
-                    subscriptionIdentifier=None, sender=None):
+    def unsubscribe(
+        self,
+        service,
+        nodeIdentifier,
+        subscriber,
+        subscriptionIdentifier=None,
+        sender=None,
+    ):
         return defer.succeed(None)
 
     def publish(self, service, nodeIdentifier, items=None, sender=None):
@@ -234,7 +245,7 @@
         def replace(item_obj):
             index = 0
             for current in node:
-                if current['id'] == item_obj['id']:
+                if current["id"] == item_obj["id"]:
                     node[index] = item_obj
                     return True
                 index += 1
@@ -246,22 +257,30 @@
                 node.append(item_obj)
         return defer.succeed(None)
 
-    def items(self, service, nodeIdentifier, maxItems=None, itemIdentifiers=None,
-              subscriptionIdentifier=None, sender=None, ext_data=None):
+    def items(
+        self,
+        service,
+        nodeIdentifier,
+        maxItems=None,
+        itemIdentifiers=None,
+        subscriptionIdentifier=None,
+        sender=None,
+        ext_data=None,
+    ):
         try:
             items = self.__items[nodeIdentifier]
         except KeyError:
             items = []
         if ext_data:
-            assert('id' in ext_data)
-            if 'rsm' in ext_data:
-                args = (0, items[0]['id'], items[-1]['id']) if items else ()
-                self.__rsm_responses[ext_data['id']] = RSMResponse(len(items), *args)
+            assert "id" in ext_data
+            if "rsm" in ext_data:
+                args = (0, items[0]["id"], items[-1]["id"]) if items else ()
+                self.__rsm_responses[ext_data["id"]] = RSMResponse(len(items), *args)
         return defer.succeed(items)
 
     def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
         node = self.__items[nodeIdentifier]
-        for item in [item for item in node if item['id'] in itemIdentifiers]:
+        for item in [item for item in node if item["id"] in itemIdentifiers]:
             node.remove(item)
         return defer.succeed(None)