コード例 #1
0
 def test_1(self):
     bloc = NewMapListBlock(['1', "CustomPL", '3', 'test', 'mode', '2'])
     self.assertEqual(1, len(bloc))
     self.assertEqual('test', bloc[0]['name'])
     self.assertEqual('mode', bloc[0]['gamemode'])
     self.assertEqual(2, bloc[0]['num_of_rounds'])
     self.assertEqual("NewMapListBlock[test:mode:2]", repr(bloc))
     self.assertEqual(0, len(bloc.getByName('MP_003')))
     self.assertEqual(1, len(bloc.getByName('test')))
コード例 #2
0
 def test_1(self):
     bloc = NewMapListBlock(['1', "CustomPL", '3', 'test', 'mode', '2'])
     self.assertEqual(1, len(bloc))
     self.assertEqual('test', bloc[0]['name'])
     self.assertEqual('mode', bloc[0]['gamemode'])
     self.assertEqual(2, bloc[0]['num_of_rounds'])
     self.assertEqual("NewMapListBlock[test:mode:2]", repr(bloc))
     self.assertEqual(0, len(bloc.getByName('MP_003')))
     self.assertEqual(1, len(bloc.getByName('test')))
コード例 #3
0
 def test_2(self):
     bloc = NewMapListBlock(
         ['2', "CustomPL", '3', 'map1', 'mode1', '1', 'map2', 'mode2', '2'])
     self.assertEqual(2, len(bloc))
     self.assertEqual('map1', bloc[0]['name'])
     self.assertEqual('mode1', bloc[0]['gamemode'])
     self.assertEqual(1, bloc[0]['num_of_rounds'])
     self.assertEqual('map2', bloc[1]['name'])
     self.assertEqual('mode2', bloc[1]['gamemode'])
     self.assertEqual(2, bloc[1]['num_of_rounds'])
     self.assertEqual("NewMapListBlock[map1:mode1:1, map2:mode2:2]",
                      repr(bloc))
     self.assertEqual(0, len(bloc.getByName('MP_003')))
     self.assertEqual(1, len(bloc.getByName('map1')))
     self.assertEqual(1, len(bloc.getByName('map2')))
     self.assertIn(0, bloc.getByName('map1'))
     self.assertIn(1, bloc.getByName('map2'))
     self.assertTrue(bloc.getByName('map1')[0]['gamemode'] == 'mode1')
     self.assertTrue(bloc.getByName('map2')[1]['gamemode'] == 'mode2')
     self.assertEqual(0, len(bloc.getByNameAndGamemode('map1', 'mode?')))
     self.assertEqual(1, len(bloc.getByNameAndGamemode('map1', 'mode1')))
     self.assertEqual(0, len(bloc.getByNameAndGamemode('map2', 'mode?')))
     self.assertEqual(1, len(bloc.getByNameAndGamemode('map2', 'mode2')))
     self.assertIn(0, bloc.getByNameAndGamemode('map1', 'mode1'))
     self.assertIn(1, bloc.getByNameAndGamemode('map2', 'mode2'))
コード例 #4
0
 def test_append_list_with_same_num_words(self):
     data1 = [1, "CustomPL", 3, 'a1', 'a2', 1]
     data2 = [1, "CustomPL", 3, 'b1', 'b2', 2]
     # check both data lists make valid NewMapListBlock individually
     mlb1 = NewMapListBlock(data1)
     self.assertEqual(1, len(mlb1))
     mlb2 = NewMapListBlock(data2)
     self.assertEqual(1, len(mlb2))
     # check both 2nd list can be appended to the 1st one.
     mlb3 = NewMapListBlock(data1)
     mlb3.append(data2)
     # check new list length
     self.assertEqual(len(mlb1) + len(mlb2), len(mlb3))
コード例 #5
0
 def test_append_list_with_different_num_words(self):
     data1 = [1, "CustomPL", 3, 'a1', 'a2', 1]
     data2 = [1, "CustomPL", 4, 'b1', 'b2', 1, 'b4']
     # check both data lists make valid NewMapListBlock individually
     self.assertEqual(1, len(NewMapListBlock(data1)))
     self.assertEqual(1, len(NewMapListBlock(data2)))
     # check both 2nd list cannot be appended to the 1st one.
     mlb1 = NewMapListBlock(data1)
     self.assertEqual(3, mlb1._num_words)
     try:
         mlb1.append(data2)
     except MapListBlockError, err:
         self.assertIn('cannot append data', str(err),
                       "expecting error message to contain 'cannot append data' but got %r instead" % err)
コード例 #6
0
 def test_cmd_rotateMap_generate_EVT_GAME_ROUND_END(self):
     # GIVEN
     when(self.parser).write(('mapList.getMapIndices', )).thenReturn([0, 1])
     when(self.parser).getFullMapRotationList().thenReturn(
         NewMapListBlock([
             '4', 'CustomPL', '3', 'MP_03', 'CombatMission', '1', 'MP_05',
             'BombSquad', '1', 'MP_10', 'Sport', '4', 'MP_013',
             'SectorControl', '4'
         ]))
     # WHEN
     self.parser.rotateMap()
     # THEN
     event = self.assert_event_was_fired("EVT_GAME_ROUND_END")
     self.assertEqual('Event<EVT_GAME_ROUND_END>(None, None, None)',
                      str(event))
コード例 #7
0
 def test_minimal(self):
     self.assertEqual(0, len(NewMapListBlock([0, "CustomPL", 3])))
     self.assertEqual('NewMapListBlock[]',
                      repr(NewMapListBlock([0, "CustomPL", 3])))
     self.assertEqual(0, len(NewMapListBlock(['0', "CustomPL", '3'])))
     tmp = NewMapListBlock(['1', "CustomPL", '3', 'test', 'mode', '2'])
     self.assertEqual(1, len(tmp), repr(tmp))
     self.assertEqual('NewMapListBlock[]',
                      repr(NewMapListBlock(['0', "CustomPL", '3'])))
     self.assertEqual(
         0,
         len(NewMapListBlock(['0', "CustomPL", '3']).getByName('MP_003')))
コード例 #8
0
 def test_append_list_with_same_num_words(self):
     data1 = [1, "CustomPL", 3, 'a1', 'a2', 1]
     data2 = [1, "CustomPL", 3, 'b1', 'b2', 2]
     # check both data lists make valid NewMapListBlock individually
     mlb1 = NewMapListBlock(data1)
     self.assertEqual(1, len(mlb1))
     mlb2 = NewMapListBlock(data2)
     self.assertEqual(1, len(mlb2))
     # check both 2nd list can be appended to the 1st one.
     mlb3 = NewMapListBlock(data1)
     mlb3.append(data2)
     # check new list length
     self.assertEqual(len(mlb1) + len(mlb2), len(mlb3))
コード例 #9
0
 def test_2(self):
     bloc = NewMapListBlock(['2', "CustomPL", '3', 'map1', 'mode1', '1', 'map2', 'mode2', '2'])
     self.assertEqual(2, len(bloc))
     self.assertEqual('map1', bloc[0]['name'])
     self.assertEqual('mode1', bloc[0]['gamemode'])
     self.assertEqual(1, bloc[0]['num_of_rounds'])
     self.assertEqual('map2', bloc[1]['name'])
     self.assertEqual('mode2', bloc[1]['gamemode'])
     self.assertEqual(2, bloc[1]['num_of_rounds'])
     self.assertEqual("NewMapListBlock[map1:mode1:1, map2:mode2:2]", repr(bloc))
     self.assertEqual(0, len(bloc.getByName('MP_003')))
     self.assertEqual(1, len(bloc.getByName('map1')))
     self.assertEqual(1, len(bloc.getByName('map2')))
     self.assertIn(0, bloc.getByName('map1'))
     self.assertIn(1, bloc.getByName('map2'))
     self.assertTrue(bloc.getByName('map1')[0]['gamemode'] == 'mode1')
     self.assertTrue(bloc.getByName('map2')[1]['gamemode'] == 'mode2')
     self.assertEqual(0, len(bloc.getByNameAndGamemode('map1', 'mode?')))
     self.assertEqual(1, len(bloc.getByNameAndGamemode('map1', 'mode1')))
     self.assertEqual(0, len(bloc.getByNameAndGamemode('map2', 'mode?')))
     self.assertEqual(1, len(bloc.getByNameAndGamemode('map2', 'mode2')))
     self.assertIn(0, bloc.getByNameAndGamemode('map1', 'mode1'))
     self.assertIn(1, bloc.getByNameAndGamemode('map2', 'mode2'))
コード例 #10
0
 def test_append_list_with_different_num_words(self):
     data1 = [1, "CustomPL", 3, 'a1', 'a2', 1]
     data2 = [1, "CustomPL", 4, 'b1', 'b2', 1, 'b4']
     # check both data lists make valid NewMapListBlock individually
     self.assertEqual(1, len(NewMapListBlock(data1)))
     self.assertEqual(1, len(NewMapListBlock(data2)))
     # check both 2nd list cannot be appended to the 1st one.
     mlb1 = NewMapListBlock(data1)
     self.assertEqual(3, mlb1._num_words)
     try:
         mlb1.append(data2)
     except MapListBlockError, err:
         self.assertIn(
             'cannot append data', str(err),
             "expecting error message to contain 'cannot append data' but got %r instead"
             % err)
コード例 #11
0
 def test_no_param(self):
     self.assertEqual(0, len(NewMapListBlock()))