36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import unittest
|
|
from munch import Munch
|
|
|
|
from mosfet.info import blocks
|
|
from mosfet.jobs.gather_crop import GatherCropStates
|
|
|
|
|
|
class CropBatchTests(unittest.TestCase):
|
|
def test_gather_crop_finishes_after_sixteen_successful_replants(self):
|
|
unripe_wheat = blocks.MCD_BLOCKS['wheat']['minStateId']
|
|
mature_wheat = blocks.MATURE_WHEAT_ID
|
|
self.assertNotEqual(unripe_wheat, mature_wheat)
|
|
|
|
class FakeWorld:
|
|
@staticmethod
|
|
def block_at(*_position):
|
|
return unripe_wheat
|
|
|
|
state = GatherCropStates(Munch(world=FakeWorld()))
|
|
state.crop = (1, 64, 1)
|
|
state.type_id = mature_wheat
|
|
|
|
for completed in range(1, state.CROPS_PER_BATCH):
|
|
state.wait_place()
|
|
self.assertEqual(state.completed_crops, completed)
|
|
self.assertIs(state.state.__func__, state.find_new_crop.__func__)
|
|
state.state = state.wait_place
|
|
|
|
state.wait_place()
|
|
self.assertEqual(state.completed_crops, 0)
|
|
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|