def test_decide_winner_only_one_deck(): """ Check for the cards from both players are from same deck and hence there can't be any repetition of cards""" with pytest.raises(ValueError, match=r".*Both sets of cards are not from same deck'*"): p1_cards = ['ace-hearts','5-spades','queen-hearts'] p2_cards = ['5-hearts', '5-spades', '6-clubs'] # '5-spades' is repetited session6.decide_winner(p1_cards,p2_cards)
def test_decide_winner_same_num_of_cards_by_players(): """ Check for both player are using same number of cards in one game""" with pytest.raises(ValueError, match=r".*Both players should use same number of cards'*"): p1_cards = ['ace-hearts','5-spades', '7-spades'] p2_cards = ['5-hearts', '6-spades','8-spades','king-hearts'] session6.decide_winner(p1_cards,p2_cards) with pytest.raises(ValueError, match=r".*Both players should use same number of cards'*"): p1_cards = ['5-hearts', '6-spades', '7-spades','king-hearts'] p2_cards = ['ace-hearts','5-spades','8-spades'] session6.decide_winner(p1_cards,p2_cards)
def test_decide_winner_same_cards_by_player(): """ Check for a player can't use same cards multiple times in one game""" with pytest.raises(ValueError, match=r".*using same card multiple times'*"): p1_cards = ['ace-hearts','5-spades', '7-spades','5-spades'] # same card '5-spades' p2_cards = ['5-hearts', '6-spades','8-spades','king-hearts'] session6.decide_winner(p1_cards,p2_cards) with pytest.raises(ValueError, match=r".*using same card multiple times'*"): p1_cards = ['5-hearts', '6-spades', '7-spades','king-hearts'] p2_cards = ['ace-hearts','5-spades','8-spades', '5-spades'] # same card '5-spades' session6.decide_winner(p1_cards,p2_cards)
def test_decide_winner_number_of_cards(): """ Check for the cards from both players are more than 2 and less than 6""" with pytest.raises(ValueError, match=r".*Only sets of 3 or 4 or 5 cards allowed'*"): p1_cards = ['ace-hearts','5-spades'] # less than 3 cards p2_cards = ['5-hearts', '6-spades'] # less than 3 cards session6.decide_winner(p1_cards,p2_cards) with pytest.raises(ValueError, match=r".*Only sets of 3 or 4 or 5 cards allowed'*"): p1_cards = ['ace-hearts','king-hearts','8-hearts','6-hearts','4-hearts', '3-hearts'] # more than 5 cards p2_cards = ['9-hearts','7-clubs','6-diamonds','5-spades', '2-hearts', '6-clubs'] # more than 5 cards session6.decide_winner(p1_cards,p2_cards)
def test_decide_winner_incorrect_players_cards(): """ Check for the valid cards are provided by players""" with pytest.raises(ValueError, match=r".*Player 1 cards are not valid'*"): p1_cards = ['ace-hearts','king-blacks','queen-hearts'] # 'king-blacks' is incrrect p2_cards = ['5-hearts', '5-spades', '6-clubs'] session6.decide_winner(p1_cards,p2_cards) with pytest.raises(ValueError, match=r".*Player 2 cards are not valid'*"): p1_cards = ['ace-hearts','queen-hearts'] p2_cards = ['5-hearts', '5-spades', '6-blacks'] # '6-blacks' is incrrect session6.decide_winner(p1_cards,p2_cards)
def test_decide_winner_4cards_each(): """Check for the winner and show the winner, 3 cards as input""" # 10 cases p1_cards = ['ace-hearts','king-hearts','queen-hearts','jack-hearts'] p2_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['10-clubs','9-clubs','8-clubs','7-clubs'] p2_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['queen-clubs','queen-hearts','queen-spades','queen-diamonds'] p2_cards = ['king-hearts','king-spades','9-diamonds','8-spades'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['king-hearts','queen-hearts','jack-hearts', '10-hearts'] p2_cards = ['9-clubs','8-clubs','7-clubs', '6-clubs'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['10-clubs','9-clubs','8-clubs','7-clubs'] p2_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['8-hearts','7-clubs','6-diamonds','5-spades'] p2_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['queen-clubs','queen-hearts','queen-spades','7-hearts'] p2_cards = ['king-spades','9-diamonds','8-spades', '4-hearts'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['jack-diamonds','jack-hearts','9-spades','9-diamonds'] p2_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 1', "This player is not winner" p1_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] p2_cards = ['king-hearts','king-spades','9-diamonds','8-spades'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 2', "This player is not winner" p1_cards = ['queen-clubs','6-hearts','4-spades', '2-diamonds'] p2_cards = ['queen-hearts','queen-spades','7-hearts', '2-clubs'] assert session6.decide_winner(p1_cards,p2_cards) == 'Player 2', "This player is not winner"
def test_decide_winner_no_one_wins(): """Check for only one player won""" p1_cards = ['8-hearts','7-clubs','6-diamonds'] p2_cards = ['queen-clubs','7-hearts','2-diamonds'] assert session6.decide_winner(p1_cards,p2_cards) == "Player 1 won, Player 2 cards didn't match the cards", 'Incorrect result'
def test_decide_winner_no_one_wins(): """Check for none of the player won""" p1_cards = ['ace-hearts','6-spades', '7-spades'] p2_cards = ['5-hearts', '3-spades','king-hearts'] assert session6.decide_winner(p1_cards,p2_cards) == 'None', 'None of the player won'
def test_manual_20_combinations(): combinations = session6_combinations.list_twenty_comb for c in combinations: assert set(c[2]) == set(session6.decide_winner(c[0], c[1])), "Result not matching for combinations"