Example #1
0
def test_lead_when_card_is_missing():
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    with pytest.raises(CardNotInHandException):
        hand.lead(Card(Suits.SPADES, Ranks.ACE))
Example #2
0
def test_legal_cards():
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    legal = hand.legal_cards(Suits.DIAMONDS)
    assert Card(Suits.DIAMONDS, Ranks.ACE) in legal
Example #3
0
def test_lead():
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    hand.lead(Card(Suits.DIAMONDS, Ranks.KING))
    assert not hand.contains_card(Card(Suits.DIAMONDS, Ranks.KING))
Example #4
0
def test_follow_raises(led_suit, card, expected_except):
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    with expected_except:
        hand.follow(led_suit, card)
Example #5
0
def test_follow(led_suit, card):
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    hand.follow(led_suit, card)
    assert not hand.contains_card(card)
Example #6
0
def test_partial_hand_fill_and_contains(suit, rank, expected):
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in test_list
    ]
    hand = BridgeHand.generate_partially_played_hand(card_list)
    assert hand.contains_card(Card(suit, rank)) == expected
Example #7
0
def test_bridge_hand_constructor(list, expected_except):
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in list
    ]
    with expected_except:
        bridge_hand = BridgeHand(card_list)
Example #8
0
def test_generate_hand(list, expected_except):
    card_list = [
        Deck.generate_card_from_index(card_index) for card_index in list
    ]
    with expected_except:
        hand = BridgeHand.generate_complete_hand(card_list)