Clarify cache chest search counts
This commit is contained in:
@@ -49,8 +49,9 @@ class CacheItemsStates:
|
||||
self.labeled_chests = w.find_labeled_chests(p, 80)
|
||||
self.checked_labeled_chests = set()
|
||||
self.trapped_chests = w.find_blocks_indexed(p, blocks.TRAPPED_CHEST_IDS)
|
||||
print('Found labeled chests:', len(self.labeled_chests),
|
||||
'trapped chests:', self.trapped_chests)
|
||||
print('Found {} labeled chests; found {} trapped chests: {}'.format(
|
||||
len(self.labeled_chests), len(self.trapped_chests),
|
||||
self.trapped_chests))
|
||||
self.state = self.choose_trapped_chest
|
||||
|
||||
def _opening_in_bad_region(self, world, opening):
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import io
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from munch import Munch
|
||||
|
||||
from minecraft.networking.types import BlockFace
|
||||
@@ -8,6 +10,26 @@ from mosfet.jobs.cache_items import CacheItemsStates
|
||||
|
||||
|
||||
class CacheItemsTests(unittest.TestCase):
|
||||
def test_chest_search_log_distinguishes_labeled_and_trapped_counts(self):
|
||||
class FakeWorld:
|
||||
@staticmethod
|
||||
def find_labeled_chests(*_args):
|
||||
return [{} for _ in range(11)]
|
||||
|
||||
@staticmethod
|
||||
def find_blocks_indexed(*_args):
|
||||
return []
|
||||
|
||||
state = CacheItemsStates(Munch(
|
||||
world=FakeWorld(), pos=(0, 64, 0)))
|
||||
output = io.StringIO()
|
||||
with redirect_stdout(output):
|
||||
state.find_trapped_chests()
|
||||
|
||||
self.assertIn(
|
||||
'Found 11 labeled chests; found 0 trapped chests: []',
|
||||
output.getvalue())
|
||||
|
||||
def test_successful_labeled_transfer_skips_placing_another_cache_chest(self):
|
||||
item_id = items.get_id('stone')
|
||||
stack = Munch(present=True, item_id=item_id, item_count=16)
|
||||
|
||||
Reference in New Issue
Block a user