예제 #1
0
def gamblers() -> List[vinte_uno.Gambler]:
    """Returns a set of Gambler objects.

    :return: a tuple of 3 Gambler objects.
    :rtype: List[vinte_uno.Gambler]
    """
    return [
        vinte_uno.Gambler(credit=1, name='Gambler 1'),
        vinte_uno.Gambler(credit=1, name='Gambler 2'),
        vinte_uno.Gambler(credit=1, name='Gambler 3'),
    ]
예제 #2
0
def test_gambler_should_not_play_game() -> None:
    """Test if gambler should not change from ready to game to gaming state.
    """
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.play()

    assert gambler.state == vinte_uno.READY_TO_GAME
예제 #3
0
def test_gambler_should_not_tweenty_one() -> None:
    """Test if gambler should not win the match with 21 rank points.

    """
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.state = vinte_uno.GAMING
    gambler.win()

    assert gambler.state == vinte_uno.GAMING
예제 #4
0
def test_gambler_should_not_bust() -> None:
    """Test if gambler should not bust.

    """
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.state = vinte_uno.GAMING
    gambler.bust()

    assert gambler.state == vinte_uno.GAMING
예제 #5
0
def test_gambler_should_stay() -> None:
    """Test if gambler should stays.
    """
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.state = vinte_uno.GAMING
    gambler.stay()

    result1 = gambler.state

    assert result1 == vinte_uno.STAYED
예제 #6
0
def test_gambler_should_play_game() -> None:
    """Test if gambler should change from ready to game to gaming state.
    """
    gambler = vinte_uno.Gambler(name='Gambler')
    previous = gambler.state
    gambler.hit(deck=vinte_uno.Deck())
    gambler.play()

    assert previous == vinte_uno.READY_TO_GAME
    assert gambler.state == vinte_uno.GAMING
예제 #7
0
def test_gambler_should_bust(fixture_hand: pytest_mock.plugin.MockFixture) -> None:
    """Test if gambler should bust.

    :param fixture_hand: object that contains a mocked fixture hand
    :type fixture_hand: pytest_mock.plugin.MockFixture
    """
    fixture_hand.return_value = 22
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.state = vinte_uno.GAMING
    gambler.bust()

    assert gambler.state == vinte_uno.BUSTED
    assert gambler.credit == 0
예제 #8
0
def test_gambler_should_tweenty_one(fixture_hand: pytest_mock.plugin.MockFixture) -> None:
    """Test if gambler should win the match with tweenty one rank points.

    :param fixture_hand: object that contains a mocked fixture hand
    :type fixture_hand: pytest_mock.plugin.MockFixture

    """
    fixture_hand.return_value = 21
    gambler = vinte_uno.Gambler(name='Gambler')
    gambler.state = vinte_uno.GAMING
    gambler.win()

    assert gambler.state == vinte_uno.TWENTY_ONE
    assert gambler.credit > 1
예제 #9
0
def test_player_should_not_hit() -> None:
    """Test if player should not hit.
    """
    deck1 = vinte_uno.Deck()
    gambler1 = vinte_uno.Gambler(name='Gambler')
    gambler1.state = vinte_uno.GAMING
    gambler1.state = vinte_uno.STAYED
    gambler1.hit(deck=deck1)
    dealer = vinte_uno.Dealer(gamblers=[gambler1])
    dealer.state = vinte_uno.HIDING
    dealer.hit(deck=deck1)

    assert gambler1.hand == 0
    assert dealer.hand == 0