Example #1
0
def test_add_cards1():
    """Adding cards to hand gives correct hand value"""
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Diamonds", "King"))
    assert test_hand.value == 10
    assert test_hand.aces == 0
Example #2
0
def test_clear_hand():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    print(test_hand.cards)
    test_hand.clear_hand()
    print(test_hand.cards)
    assert test_hand.cards == []
Example #3
0
def test_add_cards2():
    """Next 5 tests are checking aces are handled correctly"""
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 21
    assert test_hand.aces == 1
Example #4
0
def test_add_cards5():
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    test_hand.add_cards(cards.Card("Clubs", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 12
    assert test_hand.aces == 1
Example #5
0
def test_add_cards3():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 19
    assert test_hand.aces == 0
Example #6
0
def test_card_string():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds"
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds, and the Ace of Hearts"
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert (
        test_hand.hand_held()
        == "King of Diamonds, Ace of Hearts, and the Eight of Spades"
    )
Example #7
0
def test_holding():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert test_hand.holding() == [
        ("Diamonds", "King"),
        ("Hearts", "Ace"),
        ("Spades", "Eight"),
    ]
    assert test_hand.cards[0].rank == "King"
Example #8
0
def test_hand(fake_card, capsys):
    """test that hand displays correctly"""
    test_hand = cards.Hand()
    test_hand.add_cards(fake_card)
    assert test_hand.hand_held() == "King of Diamonds"
Example #9
0
def test_converting_list_to_object():
    test_hand = cards.Hand()
    test_alexa_session_attr = ["King of Diamonds", "Ace of Hearts", "Eight of Spades"]
    pass
Example #10
0
from lambda2.code.alexa import cards

player_hand, alexa_hand, deck = cards.Hand().create_initial_hand()

game_state = cards.GameState()

player_chips = cards.Chips()