def testWeekIncrement(self):
        game = Game(10, 10)

        player1 = Player("alice", "A")
        player2 = Player("bob", "B")

        secret1 = game.addPlayer(player1)
        self.assert_(player1 in game.getPlayers())
        secret2 = game.addPlayer(player2)
        self.assert_(player2 in game.getPlayers())

        game.start()
        self.assertTrue(game.isStarted())

        # Week 1
        self.assertEquals(1, game.getWeek().getWeekNum())
        game.endTurn(player1)
        self.assertEquals(1, game.getWeek().getWeekNum())
        game.endTurn(player2)

        # Week 2
        self.assertEquals(2, game.getWeek().getWeekNum())
        game.endTurn(player1)
        self.assertEquals(2, game.getWeek().getWeekNum())
        game.endTurn(player2)

        # Week 3
        self.assertEquals(3, game.getWeek().getWeekNum())
        game.endTurn(player1)
        self.assertEquals(3, game.getWeek().getWeekNum())
        game.endTurn(player2)
    def testFirstSurveyTurn(self):
        players = []
        players.append(Player("alice", "A"))
        players.append(Player("bob", "B"))

        week = Week(1, players, 5.00)

        self.assertEquals(players[0], week.getSurveyPlayer())
    def testTwoPlayers(self):
        game = Game(10, 10)

        player1 = Player("alice", "A")
        game.addPlayer(player1)
        self.assert_(player1 in game.getPlayers())

        player2 = Player("bob", "B")
        game.addPlayer(player2)
        self.assert_(player2 in game.getPlayers())

        self.assert_(player1 in game.getPlayers())
    def testTwoPlayerOrder(self):
        game = Game(10, 10)

        player1 = Player("alice", "A")
        player2 = Player("bob", "B")
        game.addPlayer(player1)
        game.addPlayer(player2)

        players = game.getPlayers()
        self.assert_(len(players) == 2)

        self.assertEquals(player1, players[0])
        self.assertEquals(player2, players[1])
    def testAddPlayer(self):
        game = Game(10, 10)

        player = Player("alice", "A")
        game.addPlayer(player)

        self.assert_(player in game.getPlayers())
    def testStartGame(self):
        game = Game(10, 10)

        player1 = Player("alice", "A")
        game.addPlayer(player1)

        self.assertEquals(False, game.isStarted())
        game.start()
        self.assertEquals(True, game.isStarted())
    def testRejoin(self):
        game = Game(10, 10)

        player1 = Player("alice", "A")

        secret1 = game.addPlayer(player1)
        self.assert_(player1 in game.getPlayers())

        self.assertRaises(WildcattingException, game.addPlayer, player1)
    def testFinishGame(self):
        game = Game(10, 10, turnCount=1)

        player1 = Player("alice", "A")
        game.addPlayer(player1)

        self.assertEquals(False, game.isStarted())
        game.start()
        self.assertEquals(True, game.isStarted())

        self.assertEquals(False, game.isFinished())
        game.endTurn(player1)
        self.assertEquals(True, game.isFinished())
    def testTurnProgression(self):
        players = []
        players.append(Player("alice", "A"))
        players.append(Player("bob", "B"))

        week = Week(1, players, 5.00)
        self.assertEquals(players[0], week.getSurveyPlayer())
        self.assertTrue(week.isSurveyTurn(players[0]))
        self.assertFalse(week.isSurveyTurn(players[1]))

        for player in players:
            self.assertFalse(week.isTurnFinished(player))

        week.endSurvey(players[0])
        self.assertEquals(players[1], week.getSurveyPlayer())
        self.assertTrue(week.isSurveyTurn(players[1]))
        self.assertFalse(week.isSurveyTurn(players[0]))

        week.endSurvey(players[1])
        self.assertEquals(None, week.getSurveyPlayer())

        for player in players:
            self.assertFalse(week.isTurnFinished(player))

        self.assert_(players[0] in week.getPendingPlayers())
        week.endTurn(players[0])
        self.assert_(players[0] not in week.getPendingPlayers())

        self.assert_(players[1] in week.getPendingPlayers())
        week.endTurn(players[1])
        self.assert_(players[1] not in week.getPendingPlayers())

        for player in players:
            self.assertTrue(week.isTurnFinished(player))

        self.assertTrue(week.isFinished())
 def testGetOilPrice(self):
     week = Week(1, [Player("alice", "A")], 5.00)
     self.assertAlmostEqual(5.00, week.getPrice())