示例#1
0
def test_should_append_card_on_cards_attribute():
    card = Card('value')
    deck = Deck()

    deck.pack(card=card)

    assert deck.cards == [card]
示例#2
0
def test_should_append_card_on_specific_position(position, index):
    card = Card('value')
    deck = Deck(cards=[Card(str(x)) for x in range(4)])

    deck.pack(card=card, position=position)

    assert deck.cards[index] == card
示例#3
0
def test_should_return_none_when_pop_raises_type_error():
    mock_cards = mock.MagicMock()
    mock_cards.pop.side_effect = IndexError

    result = Deck(cards=mock_cards).draw()

    assert result is None
示例#4
0
def test_should_call_shuffle_with_cards(mock_shuffle):
    mock_cards = mock.MagicMock()

    result = Deck(cards=mock_cards).shuffle()

    mock_shuffle.assert_called_once_with(mock_cards)
    assert result is None
示例#5
0
def test_should_return_cards_getitem_return():
    mock_cards = mock.MagicMock()

    result = Deck(cards=mock_cards).__getitem__(1)

    assert result == mock_cards.__getitem__.return_value
    mock_cards.__getitem__.assert_called_once_with(1)
示例#6
0
def test_should_get_cards_from_constant_when_default_is_true(
    mock_default_cards,
    mock_card
):
    mock_default_cards.__iter__.return_value = ('card',)

    deck = Deck(default=True)

    mock_card.assert_called_once_with(value='card')
    assert deck.cards == [mock_card.return_value]
示例#7
0
def test_should_initiate_cards_with_param():
    expected_cards = [Card('card')]

    deck = Deck(cards=expected_cards)

    assert deck.cards == expected_cards
示例#8
0
def test_should_initiate_cards_with_empty_cards():
    deck = Deck()

    assert deck.cards == []
示例#9
0
def test_should_return_len_of_cards_attribute():
    mock_cards = mock.MagicMock()

    deck = Deck(cards=mock_cards)

    assert deck.__len__() == mock_cards.__len__.return_value
示例#10
0
def test_should_return_pop_from_cards_attribute():
    mock_cards = mock.MagicMock()

    result = Deck(cards=mock_cards).draw()

    assert result == mock_cards.pop.return_value