def test_import_some_iron(example_island: main.Island): example_island.fertility["iron_mine"] = 1 iron_isle = main.Island(name="iron-isle", fertility={"iron_mine": 55}, exports={"iron_mine": 50}, world=example_island.world) example_island.requested_construction_buildings["steel_works"] = 6 # require 2 iron mines example_island.calculate_required_production_buildings() assert example_island.required_buildings["iron_mine"] == 1 assert iron_isle.required_buildings["iron_mine"] == 1
def test_cannery_numbers(example_island: main.Island, example_numbers, remove_sewing_machines): example_island.residences["artisans"] = example_numbers[0] example_island.calculate_required_production_buildings() assert math.ceil(example_island.required_buildings["cannery"]) == example_numbers[1] assert math.ceil(example_island.required_buildings["kitchen"]) == example_numbers[2] assert math.ceil(example_island.required_buildings["iron_mine"]) == example_numbers[3] assert math.ceil(example_island.required_buildings["peppers"]) == example_numbers[4] assert math.ceil(example_island.required_buildings["cattle"]) == example_numbers[5]
def test_must_import(example_island: main.Island): example_island.must_import = {"fishery"} example_island.residences["farmers"] = 100 fish_isle = main.Island(name="fish", exports={"fishery": None}, world=example_island.world) example_island.calculate_required_production_buildings() fish_isle.calculate_required_production_buildings() assert example_island.required_buildings["fishery"] == 0 assert fish_isle.required_buildings["fishery"] > 0
def test_steel_works_one_coal(example_island: main.Island): example_island.fertility["coal_mine"] = 1 example_island.requested_construction_buildings["steel_works"] = 6 example_island.calculate_required_production_buildings() assert example_island.required_buildings["coal_mine"] == 1 assert example_island.required_buildings["charcoal_kiln"] == 2 assert example_island.required_buildings["furnace"] == 4 assert example_island.required_buildings["steel_works"] == 6 assert example_island.required_buildings["iron_mine"] == 2
def test_no_sugar_export(example_island: main.Island): example_island.residences["artisans"] = 1 del example_island.fertility["sugar"] new_world = main.Island(name="newworld", fertility={"sugar": None}, exports={}, world=example_island.world) with pytest.raises(main.NoFertility): example_island.calculate_required_production_buildings()
def test_more_hops(example_island: main.Island): del example_island.fertility["hops"] example_island.residences["workers"] = 130 * 2 hop_island = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=example_island.world) example_island.calculate_required_production_buildings() hop_island.calculate_required_production_buildings() assert example_island.required_buildings["hops"] == 0 assert example_island.required_buildings["brewery"] == 4 assert hop_island.required_buildings["hops"] == 6
def test_export_rum_not_sugar(example_island: main.Island): example_island.residences["artisans"] = 1 del example_island.fertility["sugar"] new_world = main.Island(name="newworld", fertility={"sugar": None}, exports={"rum": None}, world=example_island.world) example_island.calculate_required_production_buildings() new_world.calculate_required_production_buildings()
def test_global_modifier_imports(example_island: main.Island): del example_island.fertility["potato"] potato_isle = main.Island(name="potato-isle", fertility={"potato": None}, exports={"potato": None}, world=example_island.world) main.GLOBAL_CONSUMPTION_MODIFIER = .5 example_island.residences["farmers"] = 60 example_island.calculate_required_production_buildings() assert potato_isle.required_buildings["potato"] == .5
def test_new_world_pop_beer_export(example_island: main.Island): hop_isle = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=example_island.world) beer_isle = main.Island(name="beer-isle", fertility={"grain": None}, exports={"brewery": None}, world=example_island.world) del example_island.fertility["grain"] example_island.residences["jornaleros"] = 1 example_island.residences["obreros"] = 1 example_island.calculate_required_production_buildings() beer_isle.calculate_required_production_buildings() hop_isle.calculate_required_production_buildings() assert math.ceil(beer_isle.required_buildings["brewery"]) == 1 assert math.ceil(hop_isle.required_buildings["hops"]) == 1
def test_good_clay_pit_number(example_island: main.Island): example_island.fertility["clay"] = 1 example_island.requested_construction_buildings["brick"] = 2 example_island.calculate_required_production_buildings()
def test_global_modifer_producers(example_island: main.Island): main.GLOBAL_CONSUMPTION_MODIFIER = .5 example_island.residences["farmers"] = 65 example_island.calculate_required_production_buildings() assert example_island.required_buildings["sheep"] == .5
def test_new_world_pop(example_island: main.Island): example_island.residences["jornaleros"] = 1 example_island.residences["obreros"] = 1 example_island.calculate_required_production_buildings()
def test_no_coal(example_island: main.Island): del example_island.fertility["coal_mine"] example_island.residences["artisans"] = 1 example_island.calculate_required_production_buildings()
def test_many_clay_pits(example_island: main.Island): example_island.fertility["clay"] = 1 example_island.requested_construction_buildings["brick"] = 3 with pytest.raises(main.NoFertility): example_island.calculate_required_production_buildings()
def test_all_buildings_in_required(example_island: main.Island): example_island.calculate_required_production_buildings() assert len(example_island.required_buildings) == len(main.CONSUMABLES_BUILDINGS) + len(main.CONSTRUCTION_MATERIAL_BUILDINGS)
def test_windows(example_island: main.Island): example_island.requested_construction_buildings["windows"] = 4 example_island.calculate_required_production_buildings() assert example_island.required_buildings["sand"] == 2 assert example_island.required_buildings["glass"] == 2 assert example_island.required_buildings["lumberjack"] == 1
def test_steel_works(example_island: main.Island): example_island.requested_construction_buildings["steel_works"] = 1 example_island.calculate_required_production_buildings()
def test_brewery_no_exports(example_island: main.Island): example_island.residences["workers"] = 1 example_island.calculate_required_production_buildings()
def test_schnaps_numbers(example_island: main.Island, example_numbers): example_island.residences["farmers"] = example_numbers[0] example_island.calculate_required_production_buildings() assert math.ceil(example_island.required_buildings["schnapps"]) == example_numbers[1]
def test_no_fertility_farmers(example_island: main.Island): example_island.residences["farmers"] = 1 example_island.fertility = {} with pytest.raises(main.NoFertility): example_island.calculate_required_production_buildings()