def test_buy_building_when_player_is_not_owner():
    # GIVEN
    Proxy()
    player = PlayerFactory(balance=5000, position=3, move=1)
    card = CardFactory(position=3)
    property = PropertyFactory(card=card, game=player.game, deposited=False)
    Proxy().load(full=True)
    [property,
     status] = BuildingService().buy_building(player.game_id, player.user_id)
    assert status == 2004
def test_buy_building_when_property_is_deposited():
    # GIVEN
    Proxy()
    player = PlayerFactory(position=3, move=1)
    card = CardFactory(position=3)
    property = PropertyFactory(card=card,
                               player=player,
                               game=player.game,
                               buildings=0,
                               deposited=True)
    Proxy().load(full=True)
    [property,
     status] = BuildingService().buy_building(player.game_id, player.user_id)
    assert status == 2016
def test_buy_building_when_buildings_limit_reached():
    # GIVEN
    Proxy()
    player = PlayerFactory(balance=5000, position=3)
    card = CardFactory(position=3)
    property = PropertyFactory(card=card,
                               player=player,
                               game=player.game,
                               buildings=5,
                               deposited=False)
    Proxy().load(full=True)
    [property,
     status] = BuildingService().buy_building(player.game_id, player.user_id)
    assert status == 2014
def test_buy_building_when_valid_buying_hotel():
    # GIVEN
    Proxy()
    player = PlayerFactory(balance=700, position=3, move=1)
    card = CardFactory(position=3)
    property = PropertyFactory(card=card,
                               player=player,
                               game=player.game,
                               buildings=4,
                               deposited=False)
    Proxy().load(full=True)
    [property,
     status] = BuildingService().buy_building(player.game_id, player.user_id)
    new_balance = PlayerProvider().get_player_with_id(player.id).balance
    updated_property = PropertyProvider().get_property_with_id(property.id)
    assert status == 1000
    assert updated_property.buildings == 5
    assert new_balance == 0
예제 #5
0
 def sell_building(self, game_id, user_id, card_id):
     record, status = BuildingService().sell_building(game_id=game_id,
                                                      user_id=user_id,
                                                      card_id=card_id)
     self.__prepare_response(record, status)
     return self.response