def test_addAndGetHand(): """ Testing adding of a hand object """ p = Player(money=100) # Add a blank hand p.addHand() # Make sure we got it assert len(p.getHands()) == 1 # Get it specifically h = p.getHand() assert ofType(h,"Hand") h = Hand() p.addHand(h) assert len(p.getHands()) == 2 assert ofType(p.getHand(1),"Hand") with pytest.raises(AssertionError): p.addHand("Blerg") p.clearHands() assert len(p.getHands()) == 0
def test_addAndGetHand(): """ Testing adding of a hand object """ p = Player(money=100) # Add a blank hand p.addHand() # Make sure we got it assert len(p.getHands()) == 1 # Get it specifically h = p.getHand() assert ofType(h, "Hand") h = Hand() p.addHand(h) assert len(p.getHands()) == 2 assert ofType(p.getHand(1), "Hand") with pytest.raises(AssertionError): p.addHand("Blerg") p.clearHands() assert len(p.getHands()) == 0
def test_dealCardsToTable(): """ Test dealing of cards to the table """ # Create the player player = Player(money=100, name="John") player2 = Player(money=100, name="Sue") # Create the UI ui = UI() # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the table table = Table() table.addPlayer(player) table.addPlayer(player2) # We want to hit all these cases cases = { "Insurance": False, "NotInsurance": False, "BlackJack": False, "NotBlackJack": False } # TODO: Maybe change how I check these paths? Technically this could run indefinitely long :-/ while True: # Set up the dealer each time to ensure we don't run out of cards... dealer = Dealer(houseRules=houseRules, ui=ui) table.setDealer(dealer) # Clear the table table.reset() # Do the dealing insurance, blackjack = dealer.dealHandsToTable(table) # Basic sanity checks assert len(player.getHands()) == 1 assert len(player2.getHands()) == 1 assert len(dealer.getHands()) == 1 assert len(player.getHand().getCards()) == 2 assert len(player2.getHand().getCards()) == 2 assert len(dealer.getHand().getCards()) == 2 # Update our cases to track what we've seen cases["Insurance"] |= insurance cases["NotInsurance"] |= not insurance cases["BlackJack"] |= blackjack cases["NotBlackJack"] |= not blackjack # See if we've exercized every case yet if set(cases.values()) == {True}: break
def test_dealCardsToTable(): """ Test dealing of cards to the table """ # Create the player player = Player(money=100,name="John") player2 = Player(money=100,name="Sue") # Create the UI ui = UI() # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the table table = Table() table.addPlayer(player) table.addPlayer(player2) # We want to hit all these cases cases = {"Insurance":False,"NotInsurance":False,"BlackJack":False,"NotBlackJack":False} # TODO: Maybe change how I check these paths? Technically this could run indefinitely long :-/ while True: # Set up the dealer each time to ensure we don't run out of cards... dealer = Dealer(houseRules=houseRules,ui=ui) table.setDealer(dealer) # Clear the table table.reset() # Do the dealing insurance,blackjack = dealer.dealHandsToTable(table) # Basic sanity checks assert len(player.getHands()) == 1 assert len(player2.getHands()) == 1 assert len(dealer.getHands()) == 1 assert len(player.getHand().getCards()) == 2 assert len(player2.getHand().getCards()) == 2 assert len(dealer.getHand().getCards()) == 2 # Update our cases to track what we've seen cases["Insurance"] |= insurance cases["NotInsurance"] |= not insurance cases["BlackJack"] |= blackjack cases["NotBlackJack"] |= not blackjack # See if we've exercized every case yet if set(cases.values()) == {True}: break