def test_owner_is(): p1 = Player(0) p2 = Player(0) r = RealState(50, 5, owner=p1) assert r.owner_is(p1) == True assert r.owner_is(p2) == False
def test_deal_sell(): p1 = Player(100) r1 = RealState(50, 5) r1.deal(p1) assert r1.owner_is(p1) assert p1.balance == 50
def test_rent(): p1, p2 = Player(0), Player(5) r = RealState(50, 5, owner=p1) r.rent_to(p2) assert p1.balance == 5 assert p2.balance == 0
def test_sell(): p = Player(100) r = RealState(50, 5) r.sell_to(p) assert r.owner_is(p) assert p.balance == 50
def test_deal_rent(): p1 = Player(100) p2 = Player(0) r2 = RealState(50, 5, owner=p2) r2.deal(p1) assert p2.balance == 5 assert p1.balance == 95
def test_init(): players = Player.from_strategies(300) r = RealState(100,10) g = Game(players, [r]) assert [p.balance for p in players] == [300] * 4 assert g.board
def generate_properties(how_many, median=5, stdv=1, price_scale=20, rent_scale=10): distribution = (round(random.gauss(median, stdv)) for _ in range(how_many)) params = ((value * price_scale, value * rent_scale) for value in distribution) return tuple(RealState(price, rent) for price, rent in params)
def test_leader(): players = Player.from_strategies(0) players[1].receive(1) players[2].receive(2) players[3].receive(3) r = RealState(100, 10) g = Game(players, [r]) assert g.leader == players[3]
def test_run_tie(): p1 = Player(100) p2 = Player(100) r = RealState(100, 10) g = Game([p1, p2], [r]) g.dice = lambda: 1 winner = g.run(998) assert winner is p2
def test_run_winner(mocker): p1 = Player(100) p2 = Player(0) r = RealState(100, 10) g = Game([p1, p2], [r]) g.dice = lambda: 1 winner = g.run() assert winner is p1
def test_has_owner(): p = Player(0) r = RealState(50, 5, owner=p) assert r.has_owner() == True
def test_leader_tie(): players = Player.from_strategies(0) r = RealState(100, 10) g = Game(players, [r]) assert g.leader == players[0]
def test_foreclose(): p = Player(0) r = RealState(50, 5, owner=p) r.foreclose() assert r.has_owner() == False
def test_init(): r = RealState(50, 5) assert r.price == 50 assert r.rent == 5 assert r.owner is None
def test_rent_player_is_owner(): p1 = Player(4) r1 = RealState(50, 5, owner=p1) r1.rent_to(p1) assert p1.balance == 4
def test_not_has_owner(): r = RealState(50, 5) assert r.has_owner() == False
def test_sell_error(): p1, p2 = Player(100), Player(0) r = RealState(50, 5, owner=p2) with pytest.raises(AssertionError): r.sell_to(p1)