def test_basic_deck_sort():
    deck = Deck()
    sorted_deck = deck.sort_cards(SORT_ORDER)
    assert len(sorted_deck) == 52
    assert sorted_deck == SORTED_DECK
    assert sorted_deck.top_card == SORTED_DECK[-1]

    card = sorted_deck.get_card()
    assert len(sorted_deck) == 51
    assert card == SORTED_DECK[-1]
    assert sorted_deck == SORTED_DECK[:-1]
    assert sorted_deck.top_card == SORTED_DECK[-2]

    for i in range(50, -1, -1):
        card = sorted_deck.get_card()
        assert card == SORTED_DECK[i]
    assert len(sorted_deck) == 0
    assert sorted_deck == []
    assert sorted_deck.top_card is None

    sorted_deck = sorted_deck.sort_cards(SORT_ORDER)
    assert sorted_deck == []

    deck = Deck()
    card_1 = deck.get_card()
    card_2 = deck.get_card()
    sorted_deck = deck.sort_cards(SORT_ORDER)
    assert sorted_deck == list(
        filter(lambda x: x not in [card_1, card_2], SORTED_DECK))
    assert sorted_deck.top_card == SORTED_DECK[-1]

    deck = Deck()
    deck.shuffle()
    sorted_deck = deck.sort_cards(SORT_ORDER)
    assert sorted_deck == SORTED_DECK
    assert sorted_deck.top_card == SORTED_DECK[-1]

    deck.new_deck()
    assert len(deck) == 52
    assert deck == UNSHUFFLED_DECK
    assert deck.top_card == UNSHUFFLED_DECK[-1]
def test_basic_deck_string():
    rand = Random()
    rand.seed(1)
    deck = Deck()
    assert str(deck) == str(UNSHUFFLED_DECK_TUPLES)
    deck.get_card()
    assert str(deck) == str(UNSHUFFLED_DECK_TUPLES[:-1])

    deck = Deck(random_instance=rand)
    deck.shuffle()
    assert str(deck) == str(SHUFFLED_DECK_1_TUPLES)
    deck.get_card()
    assert str(deck) == str(SHUFFLED_DECK_1_TUPLES[:-1])

    deck = Deck()
    sorted_deck = deck.sort_cards(SORT_ORDER)
    assert str(sorted_deck) == str(SORTED_DECK_TUPLES)
    sorted_deck.get_card()
    assert str(sorted_deck) == str(SORTED_DECK_TUPLES[:-1])
    for i in range(0, 51):
        sorted_deck.get_card()
    assert str(sorted_deck) == str([])