def test_minimal(self):
     blc = BanlistContent([])
     self.assertEqual(0, len(blc))
     self.assertEqual('BanlistContent[]', repr(blc))
     blc = BanlistContent()
     self.assertEqual(0, len(blc))
     self.assertEqual('BanlistContent[]', repr(blc))
     blc = BanlistContent(['name', 'Averell', 'seconds', '3600', '0', 'reason 2'])
     self.assertEqual(1, len(blc))
     self.assertEqual("BanlistContent[{'idType': 'name', 'seconds_left': '3600', 'reason': 'reason 2', 'banType': 'seconds', 'rounds_left': '0', 'id': 'Averell'}]", repr(blc))
Пример #2
0
 def test_append(self):
     data1 = ['a1','a2','a3','a4','a5','a6', 'b1','b2','b3','b4','b5','b6']
     data2 = ['c1','c2','c3','c4','c5','a6']
     # check both data lists make valid MapListBlock individually
     blc1 = BanlistContent(data1)
     self.assertEqual(2, len(blc1))
     blc2 = BanlistContent(data2)
     self.assertEqual(1, len(blc2))
     # check both 2nd list can be appended to the 1st one.
     blc3 = BanlistContent(data1)
     blc3.append(data2)
     # check new list length
     blc3_length = len(blc3)
     self.assertEqual(len(blc1) + len(blc2), blc3_length)
     # check appending empty stuff does not affect current length
     blc3.append([])
     self.assertEqual(blc3_length, len(blc3))
    def test_1(self):
        bloc = BanlistContent([
            'name', 'William', 'perm', '0', '0', 'reason 1',
            'name', 'Averell', 'seconds', '3600', '0', 'reason 2',
        ])
        self.assertEqual(2, len(bloc))
        self.assertEqual("BanlistContent[{'idType': 'name', 'seconds_left': '0', 'reason': 'reason 1', 'banType': 'perm', 'rounds_left': '0', 'id': 'William'}, \
{'idType': 'name', 'seconds_left': '3600', 'reason': 'reason 2', 'banType': 'seconds', 'rounds_left': '0', 'id': 'Averell'}]", repr(bloc))
Пример #4
0
    def test_slice(self):
        bloc = BanlistContent([
            'name',
            'William',
            'perm',
            None,
            None,
            'reason 1',
            'name',
            'Averell',
            'seconds',
            3600,
            None,
            'reason 2',
            'name',
            'Jack',
            'rounds',
            None,
            2,
            'reason 3',
            'name',
            'Joe',
            'seconds',
            120,
            None,
            'reason 4',
            'guid',
            'EA_ababab564ba654ba654ba',
            'seconds',
            120,
            None,
            'reason 4',
        ])
        self.assertEqual(5, len(bloc))
        self.assertEqual(2, len(bloc[1:3]))
        print(bloc[1:3])
        self.assertEqual('name', bloc[1:3][0]['idType'])
        self.assertEqual('Averell', bloc[1:3][0]['id'])
        self.assertEqual('seconds', bloc[1:3][0]['banType'])
        self.assertEqual(3600, bloc[1:3][0]['seconds_left'])
        self.assertEqual(None, bloc[1:3][0]['rounds_left'])
        self.assertEqual('reason 2', bloc[1:3][0]['reason'])

        self.assertEqual('name', bloc[1:3][1]['idType'])
        self.assertEqual('Jack', bloc[1:3][1]['id'])
        self.assertEqual('rounds', bloc[1:3][1]['banType'])
        self.assertEqual(None, bloc[1:3][1]['seconds_left'])
        self.assertEqual(2, bloc[1:3][1]['rounds_left'])
        self.assertEqual('reason 3', bloc[1:3][1]['reason'])
 def test_append(self):
     data1 = ['a1','a2','a3','a4','a5','a6', 'b1','b2','b3','b4','b5','b6']
     data2 = ['c1','c2','c3','c4','c5','a6']
     # check both data lists make valid MapListBlock individually
     blc1 = BanlistContent(data1)
     self.assertEqual(2, len(blc1))
     blc2 = BanlistContent(data2)
     self.assertEqual(1, len(blc2))
     # check both 2nd list can be appended to the 1st one.
     blc3 = BanlistContent(data1)
     blc3.append(data2)
     # check new list length
     blc3_length = len(blc3)
     self.assertEqual(len(blc1) + len(blc2), blc3_length)
     # check appending empty stuff does not affect current length
     blc3.append([])
     self.assertEqual(blc3_length, len(blc3))