コード例 #1
0
    def setUp(self):
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""
                <configuration>
                </configuration>
            """)
        self.parser = AbstractParser(self.conf)
        self.parser.startup()

        # simulate responses we can expect from the rcon command mapList.list
        def write(data):
            if type(data) in (tuple, list):
                if data[0].lower() == 'maplist.list':
                    offset = 0
                    if len(data) > 1:
                        try:
                            offset = int(data[1])
                        except ValueError:
                            raise CommandFailedError(['InvalidArguments'])
                        # simulate that the Frostbite2 server responds with 5 maps at most for the mapList.list command
                    maps_to_send = self.__class__.maps[offset:offset + 5]
                    return [len(maps_to_send), 3] + list(
                        reduce(tuple.__add__, maps_to_send, tuple()))
                elif data[0].lower() == 'maplist.getmapindices':
                    return self.__class__.map_indices
            return []

        self.parser.write = Mock(side_effect=write)

        self.parser.getEasyName = Mock(side_effect=lambda x: x)
        self.parser.getGameMode = Mock(side_effect=lambda x: x)
コード例 #2
0
    def setUp(self):

        self.conf = XmlConfigParser()
        self.conf.loadFromString("""
                <configuration>
                </configuration>
            """)
        self.parser = AbstractParser(self.conf)
        self.parser.startup()

        # simulate responses we can expect from the rcon command mapList.list
        def write(data):
            if type(data) in (tuple, list):
                if data[0].lower() == 'banlist.list':
                    offset = 0
                    if len(data) > 1:
                        try:
                            offset = int(data[1])
                        except ValueError:
                            raise CommandFailedError(['InvalidArguments'])
                            # simulate that the Frostbite2 server responds with 5 bans at most for the banList.list command
                    bans_to_send = self.__class__.bans[offset:offset + 5]
                    return list(reduce(tuple.__add__, bans_to_send, tuple()))
            return []

        self.parser.write = Mock(side_effect=write)
コード例 #3
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""
             <configuration>
             </configuration>
         """)
     self.parser = AbstractParser(self.conf)
     # setup context
     self.foobar = self.parser.clients.newClient(cid='Foobar',
                                                 name='Foobar',
                                                 guid="aaaaaaa5555555")
     self.joe = self.parser.clients.newClient(cid='joe',
                                              name='joe',
                                              guid="bbbbbbbb5555555")
     self.jack = self.parser.clients.newClient(cid='jack',
                                               name='jack',
                                               guid="ccccccccc5555555")
     self.jacky = self.parser.clients.newClient(cid='jacky',
                                                name='jacky',
                                                guid="ddddddddd5555555")
     self.p123456 = self.parser.clients.newClient(cid='123456',
                                                  name='123456',
                                                  guid="eeeeeee5555555")
コード例 #4
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""<configuration/>""")
     self.parser = AbstractParser(self.conf)
     log = logging.getLogger('output')
     log.setLevel(logging.DEBUG)