Example #1
0
def test_farmer_produce():
    farmer = market.NPC(occupation="farmer")
    npc = farmer._replace(inventory=market.Inventory(tools=0, wood=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory == npc.inventory

    npc = farmer
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.food == npc.inventory.food + 4
    assert updated_npc.inventory.wood == npc.inventory.wood - 1

    npc = farmer._replace(inventory=market.Inventory(tools=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.food == npc.inventory.food + 2
    assert updated_npc.inventory.wood == npc.inventory.wood - 1
Example #2
0
def test_miner_produce():
    miner = market.NPC(occupation="miner")
    npc = miner._replace(inventory=market.Inventory(tools=0, food=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory == npc.inventory

    npc = miner
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.ore == npc.inventory.ore + 4
    assert updated_npc.inventory.food == npc.inventory.food - 1

    npc = miner._replace(inventory=market.Inventory(tools=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.ore == npc.inventory.ore + 2
    assert updated_npc.inventory.food == npc.inventory.food - 1
Example #3
0
def test_refiner_produce():
    refiner = market.NPC(occupation="refiner")
    npc = refiner._replace(inventory=market.Inventory(tools=0, food=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory == npc.inventory

    npc = refiner
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.metal == npc.inventory.metal + 1
    assert updated_npc.inventory.ore == 0
    assert updated_npc.inventory.food == npc.inventory.food - 1

    npc = refiner._replace(inventory=market.Inventory(tools=0))
    updated_npc = market.do_work(npc)
    assert updated_npc.inventory.metal == npc.inventory.metal + 1
    assert updated_npc.inventory.ore == npc.inventory.ore - 2
    assert updated_npc.inventory.food == npc.inventory.food - 1