def test2(self): # # Two 5 seats tables (0, 1) # table 0 : 2 players # table 1 : 3 players # games = self.games[:2] games[0].serial2player = {} games[0].max_players = 5 for serial in (1, 2): games[0].serial2player[serial] = None games[1].serial2player = {} games[1].max_players = 5 for serial in (100, 101, 102): games[1].serial2player[serial] = None self.assertEqual(breakGames(games), [(0, 1, [1, 2])])
def test3(self): """ """ # # Five 10 seats tables (0 to 4), each with 5 players # counts = [5] * NGAMES for game in self.games: for serial in xrange(counts.pop()): game.serial2player[game.id * 100 + serial] = None game.state = "turn" # # Tables 0, 1, 2, 3 are running and will not be broken. # Only table 4 is not running and can be broken. # self.games[4].state = "end" # # Players from table 4 go to table 3 # self.assertEqual(breakGames(self.games[:]), [(4, 3, [400, 401, 402, 403, 404])])
def test3(self): """ """ # # Five 10 seats tables (0 to 4), each with 5 players # counts = [5] * NGAMES for game in self.games: for serial in xrange(counts.pop()): game.serial2player[game.id * 100 + serial] = None game.state = "turn" # # Tables 0, 1, 2, 3 are running and will not be broken. # Only table 4 is not running and can be broken. # self.games[4].state = "end" # # Players from table 4 go to table 3 # self.assertEqual(breakGames(self.games), [(4, 3, [400, 401, 402, 403, 404])])
def test1(self): """ """ # # Five 10 seats tables (0 to 4), each with 5 players # counts = [5] * NGAMES for game in self.games: for serial in xrange(counts.pop()): game.serial2player[game.id * 100 + serial] = None # # Players from table 0 go to table 4 # Players from table 1 to to table 3 # self.assertEqual(breakGames(self.games[:]), [ (0, 4, [0, 1, 2, 3, 4]), (1, 3, [104, 100, 101, 102, 103]) ]) # # Five 10 seats tables (0 to 4), table 0 with 10 players, # tables 1 to 4 with 5 players # for serial in xrange(5,10): self.games[0].serial2player[serial] = None # # Players from table 1 go to table 4 # Players from table 2 go to table 3 # self.assertEqual(breakGames(self.games[:]), [ (1, 4, [104, 100, 101, 102, 103]), (2, 3, [200, 201, 202, 203, 204]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 7 players # table 2 : 7 players # table 3 : 7 players # table 4 : 7 players # for game in self.games: for serial in xrange(5,7): game.serial2player[game.id * 100 + serial] = None # # Players from table 1 are spread on tables # 4, 3, 2 # self.assertEqual(breakGames(self.games[:]), [ (1, 4, [100, 101, 102]), (1, 3, [103, 104, 105]), (1, 2, [106]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 7 players # table 2 : 7 players # table 3 : 9 players # table 4 : 7 players # for serial in xrange(7,9): self.games[3].serial2player[300 + serial] = None # # Players from table 1 are spread on tables # 3, 4, 2. Table 3 is chosen first because it is the # table with the largest number of players. # self.assertEqual(breakGames(self.games[:]), [ (1, 3, [100]), (1, 4, [101, 102, 103]), (1, 2, [104, 105, 106]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 8 players # table 2 : 7 players # table 3 : 9 players # table 4 : 7 players # for serial in xrange(7,8): self.games[1].serial2player[100 + serial] = None # # Can't break any table : 6 free seats and smallest table # has seven players. # self.assertEqual(breakGames(self.games[:]), [])
def test1(self): """ """ # # Five 10 seats tables (0 to 4), each with 5 players # counts = [5] * NGAMES for game in self.games: for serial in xrange(counts.pop()): game.serial2player[game.id * 100 + serial] = None # # Players from table 0 go to table 4 # Players from table 1 to to table 3 # self.assertEqual(breakGames(self.games), [ (0, 4, [0, 1, 2, 3, 4]), (1, 3, [104, 100, 101, 102, 103]) ]) # # Five 10 seats tables (0 to 4), table 0 with 10 players, # tables 1 to 4 with 5 players # for serial in xrange(5,10): self.games[0].serial2player[serial] = None # # Players from table 1 go to table 4 # Players from table 2 go to table 3 # self.assertEqual(breakGames(self.games), [ (1, 4, [104, 100, 101, 102, 103]), (2, 3, [200, 201, 202, 203, 204]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 7 players # table 2 : 7 players # table 3 : 7 players # table 4 : 7 players # for game in self.games: for serial in xrange(5,7): game.serial2player[game.id * 100 + serial] = None # # Players from table 1 are spread on tables # 4, 3, 2 # self.assertEqual(breakGames(self.games), [ (1, 4, [100, 101, 102]), (1, 3, [103, 104, 105]), (1, 2, [106]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 7 players # table 2 : 7 players # table 3 : 9 players # table 4 : 7 players # for serial in xrange(7,9): self.games[3].serial2player[300 + serial] = None # # Players from table 1 are spread on tables # 3, 4, 2. Table 3 is chosen first because it is the # table with the largest number of players. # self.assertEqual(breakGames(self.games), [ (1, 3, [100]), (1, 4, [101, 102, 103]), (1, 2, [104, 105, 106]) ]) # # Five 10 seats tables (0 to 4) # table 0 : 10 players # table 1 : 8 players # table 2 : 7 players # table 3 : 9 players # table 4 : 7 players # for serial in xrange(7,8): self.games[1].serial2player[100 + serial] = None # # Can't break any table : 6 free seats and smallest table # has seven players. # self.assertEqual(breakGames(self.games), [])