Ejemplo n.º 1
0
 def startup(self):
     """
     Called after the parser is created before run().
     """
     AbstractParser.startup(self)
     self.clients.newClient('Server', guid='Server', name='Server', hide=True, pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)
     self.verbose('Gametype: %s, Map: %s' % (self.game.gameType, self.game.mapName))
Ejemplo n.º 2
0
    def startup(self):
        AbstractParser.startup(self)
        
        # create the 'Server' client
        self.clients.newClient('Server', guid='Server', name='Server', hide=True, pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)

        self.verbose('GameType: %s, Map: %s' %(self.game.gameType, self.game.mapName))
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def startup(self):
     """
     Called after the parser is created before run().
     """
     AbstractParser.startup(self)
     self.clients.newClient('Server', guid='Server', name='Server', hide=True, pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)
     self.verbose('Gametype: %s, Map: %s' % (self.game.gameType, self.game.mapName))
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def startup(self):
        AbstractParser.startup(self)
        
        # create the 'Server' client
        self.clients.newClient('Server', guid='Server', name='Server', hide=True, pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)

        self.verbose('GameType: %s, Map: %s' %(self.game.gameType, self.game.mapName))
Ejemplo n.º 7
0
 def pluginsStarted(self):
     """
     Called after the parser loaded and started all plugins.
     """
     AbstractParser.pluginsStarted(self)
     self.info('Connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         self.getClient(cid)
Ejemplo n.º 8
0
class Write_controlled_TestCase(AbstractParser_TestCase):
    """
    Test case that controls replies given by the parser write method as follow :

    ## mapList.list
    Responds with the maps found on class properties 'maps'.
    Response contains 5 maps at most ; to get other maps, you have to use the 'StartOffset' command parameter that appears
    from BF3 R12 release.

    ## mapList.getMapIndices
    Responds with the value of the class property 'map_indices'.

    ## getEasyName
    Responds with whatever argument was passed to it.

    ## getGameMode
    Responds with whatever argument was passed to it.
    """

    maps = (
        ('MP_001 ', 'ConquestLarge0', '2'),
        ('MP_002 ', 'Rush0', '2'),
        ('MP_003 ', 'ConquestLarge0', '2'),
    )
    map_indices = [1, 2]

    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)
Ejemplo n.º 9
0
 def pluginsStarted(self):
     """
     Called after the parser loaded and started all plugins.
     """
     AbstractParser.pluginsStarted(self)
     self.info('Connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         self.getClient(cid)
Ejemplo n.º 10
0
    def startup(self):
        AbstractParser.startup(self)
        
        # create the 'Server' client
        self.clients.newClient('Server', guid='Server', name='Server', hide=True, pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)

        self.load_conf_max_say_line_length()
        self.load_config_message_delay()

        self.verbose('GameType: %s, Map: %s' %(self.game.gameType, self.game.mapName))
Ejemplo n.º 11
0
class Write_controlled_TestCase(AbstractParser_TestCase):
    """
    Test case that controls replies given by the parser write method as follow :

    ## mapList.list
    Responds with the maps found on class properties 'maps'.
    Response contains 5 maps at most ; to get other maps, you have to use the 'StartOffset' command parameter that appears
    from BF3 R12 release.

    ## mapList.getMapIndices
    Responds with the value of the class property 'map_indices'.

    ## getEasyName
    Responds with whatever argument was passed to it.

    ## getGameMode
    Responds with whatever argument was passed to it.
    """

    maps = (("MP_001 ", "ConquestLarge0", "2"), ("MP_002 ", "Rush0", "2"), ("MP_003 ", "ConquestLarge0", "2"))
    map_indices = [1, 2]

    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)
Ejemplo n.º 12
0
 def pluginsStarted(self):
     AbstractParser.pluginsStarted(self)
     self.info('connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         client = self.clients.getByCID(cid)
         if not client:
             #self.clients.newClient(playerdata['cid'], guid=playerdata['guid'], name=playerdata['name'], team=playerdata['team'], squad=playerdata['squad'])
             name = p['name']
             self.debug('client %s found on the server' % cid)
             client = self.clients.newClient(cid, guid=p['name'], name=name, team=p['teamId'], squad=p['squadId'], data=p)
             self.queueEvent(b3.events.Event(b3.events.EVT_CLIENT_JOIN, p, client))
Ejemplo n.º 13
0
 def pluginsStarted(self):
     AbstractParser.pluginsStarted(self)
     self.info('connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         client = self.clients.getByCID(cid)
         if not client:
             #self.clients.newClient(playerdata['cid'], guid=playerdata['guid'], name=playerdata['name'], team=playerdata['team'], squad=playerdata['squad'])
             name = p['name']
             self.debug('client %s found on the server' % cid)
             client = self.clients.newClient(cid, guid=p['name'], name=name, team=p['teamId'], squad=p['squadId'], data=p)
             self.queueEvent(b3.events.Event(b3.events.EVT_CLIENT_JOIN, p, client))
Ejemplo n.º 14
0
 def pluginsStarted(self):
     """
     Called after the parser loaded and started all plugins.
     """
     AbstractParser.pluginsStarted(self)
     self.info('Connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         client = self.clients.getByCID(cid)
         if not client:
             self.debug('Client %s found on the server' % cid)
             client = self.clients.newClient(cid, guid=p['name'], name=p['name'], team=p['teamId'], squad=p['squadId'], data=p)
             self.queueEvent(self.getEvent('EVT_CLIENT_JOIN', data=p, client=client))
Ejemplo n.º 15
0
 def pluginsStarted(self):
     """
     Called after the parser loaded and started all plugins.
     """
     AbstractParser.pluginsStarted(self)
     self.info('Connecting all players...')
     plist = self.getPlayerList()
     for cid, p in plist.iteritems():
         client = self.clients.getByCID(cid)
         if not client:
             self.debug('Client %s found on the server' % cid)
             client = self.clients.newClient(cid, guid=p['name'], name=p['name'], team=p['teamId'], squad=p['squadId'], data=p)
             self.queueEvent(self.getEvent('EVT_CLIENT_JOIN', data=p, client=client))
Ejemplo n.º 16
0
    def startup(self):
        """
        Called after the parser is created before run().
        """
        AbstractParser.startup(self)

        # create event for comrose actions
        self.Events.createEvent('EVT_CLIENT_COMROSE', 'Client Comrose')
        self.Events.createEvent('EVT_CLIENT_DISCONNECT_REASON', 'Client disconnected')

        # create the 'Server' client
        self.clients.newClient('Server', guid='Server', name='Server', hide=True,
                               pbid='Server', team=b3.TEAM_UNKNOWN, squad=None)

        self.verbose('Gametype: %s, Map: %s' %(self.game.gameType, self.game.mapName))
Ejemplo n.º 17
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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
    def startup(self):
        """
        Called after the parser is created before run().
        """
        AbstractParser.startup(self)

        # create event for comrose actions
        self.Events.createEvent('EVT_CLIENT_COMROSE', 'Client Comrose')
        self.Events.createEvent('EVT_CLIENT_DISCONNECT_REASON',
                                'Client disconnected')

        # create the 'Server' client
        self.clients.newClient('Server',
                               guid='Server',
                               name='Server',
                               hide=True,
                               pbid='Server',
                               team=b3.TEAM_UNKNOWN,
                               squad=None)

        self.verbose('Gametype: %s, Map: %s' %
                     (self.game.gameType, self.game.mapName))
class Test_config_ban_agent(AbstractParser_TestCase):
    def setUp(self):
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""<configuration/>""")
        self.parser = AbstractParser(self.conf)
        log = logging.getLogger('output')
        log.setLevel(logging.DEBUG)

    def assert_both(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertNotEqual(None, self.parser.PunkBuster)
        self.assertTrue(self.parser.ban_with_server)

    def assert_punkbuster(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertNotEqual(None, self.parser.PunkBuster)
        self.assertFalse(self.parser.ban_with_server)

    def assert_frostbite(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertEqual(None, self.parser.PunkBuster)
        self.assertTrue(self.parser.ban_with_server)

    def test_both(self):
        self.assert_both(
            """<configuration><settings name="server"><set name="ban_agent">both</set></settings></configuration>"""
        )
        self.assert_both(
            """<configuration><settings name="server"><set name="ban_agent">BOTH</set></settings></configuration>"""
        )

    def test_punkbuster(self):
        self.assert_punkbuster(
            """<configuration><settings name="server"><set name="ban_agent">punkbuster</set></settings></configuration>"""
        )
        self.assert_punkbuster(
            """<configuration><settings name="server"><set name="ban_agent">PUNKBUSTER</set></settings></configuration>"""
        )

    def test_frostbite(self):
        self.assert_frostbite(
            """<configuration><settings name="server"><set name="ban_agent">server</set></settings></configuration>"""
        )
        self.assert_frostbite(
            """<configuration><settings name="server"><set name="ban_agent">SERVER</set></settings></configuration>"""
        )

    def test_default(self):
        self.assert_frostbite("""<configuration/>""")
        self.assert_frostbite(
            """<configuration><settings name="server"><set name="ban_agent"></set></settings></configuration>"""
        )
        self.assert_frostbite(
            """<configuration><settings name="server"><set name="ban_agent"/></settings></configuration>"""
        )
class Test_config_ban_agent(AbstractParser_TestCase):

    def setUp(self):
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""<configuration/>""")
        self.parser = AbstractParser(self.conf)
        log = logging.getLogger('output')
        log.setLevel(logging.DEBUG)

    def tearDown(self):
        self.parser.working = False

    def assert_both(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertNotEqual(None, self.parser.PunkBuster)
        self.assertTrue(self.parser.ban_with_server)

    def assert_punkbuster(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertNotEqual(None, self.parser.PunkBuster)
        self.assertFalse(self.parser.ban_with_server)

    def assert_frostbite(self, config):
        self.conf.loadFromString(config)
        self.parser.load_conf_ban_agent()
        self.assertEqual(None, self.parser.PunkBuster)
        self.assertTrue(self.parser.ban_with_server)

    def test_both(self):
        self.assert_both("""<configuration><settings name="server"><set name="ban_agent">both</set></settings></configuration>""")
        self.assert_both("""<configuration><settings name="server"><set name="ban_agent">BOTH</set></settings></configuration>""")

    def test_punkbuster(self):
        self.assert_punkbuster("""<configuration><settings name="server"><set name="ban_agent">punkbuster</set></settings></configuration>""")
        self.assert_punkbuster("""<configuration><settings name="server"><set name="ban_agent">PUNKBUSTER</set></settings></configuration>""")

    def test_frostbite(self):
        self.assert_frostbite("""<configuration><settings name="server"><set name="ban_agent">server</set></settings></configuration>""")
        self.assert_frostbite("""<configuration><settings name="server"><set name="ban_agent">SERVER</set></settings></configuration>""")

    def test_default(self):
        self.assert_frostbite("""<configuration/>""")
        self.assert_frostbite("""<configuration><settings name="server"><set name="ban_agent"></set></settings></configuration>""")
        self.assert_frostbite("""<configuration><settings name="server"><set name="ban_agent"/></settings></configuration>""")
Ejemplo n.º 22
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")
Ejemplo n.º 23
0
 def __new__(cls, *args, **kwargs):
     Bf3Parser.patch_b3_Client_isAlive()
     return AbstractParser.__new__(cls)
Ejemplo n.º 24
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""<configuration/>""")
     self.parser = AbstractParser(self.conf)
     log = logging.getLogger('output')
     log.setLevel(logging.DEBUG)
Ejemplo n.º 25
0
 def __new__(cls, *args, **kwargs):
     Bf3Parser.patch_b3_Client_isAlive()
     return AbstractParser.__new__(cls)
Ejemplo n.º 26
0
 def __new__(cls, *args, **kwargs):
     BfhParser.patch_b3_client_properties()
     return AbstractParser.__new__(cls)
Ejemplo n.º 27
0
class Test_getFullBanList(Write_controlled_TestCase):
    """
    getFullBanList is a method of AbstractParser that calls the Frostbite2 banList.list command the number of
    times required to obtain the exhaustive list of bans.
    """

    bans = (
        ("name", "Joe", "perm", "0", "0", "Banned by admin"),
        ("name", "Jack", "rounds", "0", "4", "tk"),
        ("name", "Averell", "seconds", "3576", "0", "being stupid"),
        ("name", "William", "perm", "0", "0", "hacking"),
    )

    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)

    def test_empty(self):
        # setup context
        self.__class__.bans = tuple()
        # verify
        bl = self.parser.getFullBanList()
        self.assertEqual(0, len(bl))
        self.assertEqual(1, self.parser.write.call_count)

    def test_one_ban(self):
        # setup context
        self.__class__.bans = (("name", "Foo1 ", "perm", "0", "0", "Banned by admin"),)
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(
            "BanlistContent[{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo1 '}]",
            repr(mlb),
        )
        self.assertEqual(2, self.parser.write.call_count)

    def test_two_bans(self):
        # setup context
        self.__class__.bans = (
            ("name", "Foo1 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo2 ", "perm", "0", "0", "Banned by admin"),
        )
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(
            "BanlistContent[{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo1 '}, \
{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo2 '}]",
            repr(mlb),
        )
        self.assertEqual(2, self.parser.write.call_count)

    def test_lots_of_bans(self):
        # setup context
        self.__class__.bans = (
            ("name", "Foo1 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo2 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo3 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo4 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo5 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo6 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo7 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo8 ", "perm", "0", "0", "Banned by admin"),
            ("name", "Foo9 ", "perm", "0", "0", "Banned by admin"),
        )
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(9, len(mlb))
        # check in details what were the 3 calls made to the write method
        assert [
            ((("banList.list", 0),), {}),
            ((("banList.list", 5),), {}),
            ((("banList.list", 10),), {}),
        ], self.parser.write.call_args_list
Ejemplo n.º 28
0
 def setUp(self):
     self.conf = XmlConfigParser()
     self.conf.loadFromString("""<configuration/>""")
     self.parser = AbstractParser(self.conf)
     log = logging.getLogger('output')
     log.setLevel(logging.DEBUG)
Ejemplo n.º 29
0
 def __new__(cls, *args, **kwargs):
     Bf4Parser.patch_b3_Client_properties()
     return AbstractParser.__new__(cls)
Ejemplo n.º 30
0
class Test_getFullBanList(Write_controlled_TestCase):
    """
    getFullBanList is a method of AbstractParser that calls the Frostbite2 banList.list command the number of
    times required to obtain the exhaustive list of bans.
    """

    bans = (
        ('name', 'Joe', 'perm', '0', '0', 'Banned by admin'),
        ('name', 'Jack', 'rounds', '0', '4', 'tk'),
        ('name', 'Averell', 'seconds', '3576', '0', 'being stupid'),
        ('name', 'William', 'perm', '0', '0', 'hacking'),
    )

    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)

    def test_empty(self):
        # setup context
        self.__class__.bans = tuple()
        # verify
        bl = self.parser.getFullBanList()
        self.assertEqual(0, len(bl))
        self.assertEqual(1, self.parser.write.call_count)

    def test_one_ban(self):
        # setup context
        self.__class__.bans = (('name', 'Foo1 ', 'perm', '0', '0',
                                'Banned by admin'), )
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(
            "BanlistContent[{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo1 '}]",
            repr(mlb))
        self.assertEqual(2, self.parser.write.call_count)

    def test_two_bans(self):
        # setup context
        self.__class__.bans = (
            ('name', 'Foo1 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo2 ', 'perm', '0', '0', 'Banned by admin'),
        )
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(
            "BanlistContent[{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo1 '}, \
{'idType': 'name', 'seconds_left': '0', 'reason': 'Banned by admin', 'banType': 'perm', 'rounds_left': '0', 'id': 'Foo2 '}]",
            repr(mlb))
        self.assertEqual(2, self.parser.write.call_count)

    def test_lots_of_bans(self):
        # setup context
        self.__class__.bans = (
            ('name', 'Foo1 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo2 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo3 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo4 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo5 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo6 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo7 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo8 ', 'perm', '0', '0', 'Banned by admin'),
            ('name', 'Foo9 ', 'perm', '0', '0', 'Banned by admin'),
        )
        # verify
        mlb = self.parser.getFullBanList()
        self.assertEqual(9, len(mlb))
        # check in details what were the 3 calls made to the write method
        assert [
            ((('banList.list', 0), ), {}),
            ((('banList.list', 5), ), {}),
            ((('banList.list', 10), ), {}),
        ], self.parser.write.call_args_list