예제 #1
0
def test_buy_single_card():
    game = Game.initialize()
    set_up(game)
    game.next_up = 2
    index = 3
    # Let's keep the current open cards as reference
    open_cards = list(game.open_cards)
    player_s_cards = list(game.player2.cards)
    top_card = game.cards[0]
    cards_left = len(game.cards)
    outcome = buy_one(game, index)
    with soft_assertions():
        assert_that(Card.camel()).is_equal_to(Card.camel())
        assert_that(game).has_next_up(1)
        assert_that(game.open_cards).is_length(5)
        assert_that(game.cards).is_length(cards_left - 1)
        assert_that(
            game.open_cards).is_equal_to(open_cards[:index] + [top_card] +
                                         open_cards[index + 1:])
        assert_that(game.player2.cards).is_equal_to(player_s_cards +
                                                    [open_cards[index]])
        assert_that(outcome).is_equal_to(Outcomes.NEXT_PLAYER)
예제 #2
0
def test_buy_single_card_too_many_non_camel():
    game = Game.initialize()
    set_up(game)
    game.next_up = 1
    # Give next player 7 cards
    game.player1.cards = [Card(kind=CardKinds.Leather)] * 7

    open_cards = list(game.open_cards)
    player_s_cards = list(game.player2.cards)
    top_card = game.cards[0]
    cards_left = len(game.cards)

    outcome = buy_one(game, 2)
    with soft_assertions():
        assert_that(outcome).is_equal_to(Outcomes.TOO_MANY_CARDS)
        assert_that(game.cards).is_length(cards_left)
        assert_that(game.player1.cards).is_length(7)
예제 #3
0
def test_non_camel_cards_only_from_card_list():
  cards = [Card(kind=CardKinds.Gems), Card(kind=CardKinds.Gold)]

  assert_that(non_camel_cards(cards=cards)).is_length(2)
예제 #4
0
def test_non_camel_cards_none_from_card_list():
  cards = [Card.camel(), Card.camel(), Card.camel()]

  assert_that(non_camel_cards(cards=cards)).is_empty()
예제 #5
0
def test_camel_cards_some():
  player = Player.initialize()
  player.cards = [Card.camel(), Card(kind=CardKinds.Gems), Card(kind=CardKinds.Gems), Card.camel(), Card(kind=CardKinds.Gold)]

  assert_that(camel_cards(player=player)).is_length(2)
예제 #6
0
def test_non_camel_cards_some_from_card_list():
  cards = [Card(kind=CardKinds.Leather), Card.camel(), Card(kind=CardKinds.Gems), Card.camel(), Card(kind=CardKinds.Gold)]

  assert_that(non_camel_cards(cards=cards)).is_length(3)
예제 #7
0
def test_camel_cards_only_from_card_list():
  cards = [Card.camel(), Card.camel(), Card.camel()]

  assert_that(camel_cards(cards=cards)).is_length(3)
예제 #8
0
def test_camel_cards_none_from_card_list():
  cards = [Card(kind=CardKinds.Gems), Card(kind=CardKinds.Gold)]

  assert_that(camel_cards(cards=cards)).is_empty()
예제 #9
0
def test_non_camel_cards_none():
  player = Player.initialize()
  player.cards = [Card.camel(), Card.camel(), Card.camel()]

  assert_that(non_camel_cards(player=player)).is_empty()
예제 #10
0
def test_camel_cards_only():
  player = Player.initialize()
  player.cards = [Card.camel(), Card.camel(), Card.camel()]

  assert_that(camel_cards(player=player)).is_length(3)
예제 #11
0
def test_camel_cards_none():
  player = Player.initialize()
  player.cards = [Card(kind=CardKinds.Gems), Card(kind=CardKinds.Gold)]

  assert_that(camel_cards(player=player)).is_empty()