Recover sleep job after time skips
This commit is contained in:
1 parent
e019752ffd
commit
f799a9ea47
2 files changed
+52
-3
No files matched your search
@@ -366,6 +366,51 @@ class TestSleepWithBed(unittest.TestCase):
|
||||
self.assertEqual(state.state, state.use_bed)
|
||||
self.assertTrue(state.waiting_for_night)
|
||||
|
||||
def test_time_set_to_100_ends_confirmed_sleep(self):
|
||||
bed_id = next(iter(blocks.BED_IDS))
|
||||
|
||||
class VacatedWorld(FakeWorld):
|
||||
def find_threats(self, center, distance):
|
||||
return []
|
||||
|
||||
state = SleepWithBedStates(Munch(
|
||||
time=100, pos=(0, 64, 0), world=VacatedWorld(block=bed_id),
|
||||
game=FakeGame(), path=[], look_at=None, correction_count=0))
|
||||
state.area = (0, 64, 0)
|
||||
state.my_bed = True
|
||||
state.sleep_confirmed = True
|
||||
|
||||
state.sleep_bed()
|
||||
|
||||
self.assertEqual(state.state, state.break_bed)
|
||||
|
||||
def test_unoccupied_bed_ends_confirmed_sleep_even_with_stale_night_clock(self):
|
||||
bed_id = next(iter(blocks.BED_IDS))
|
||||
|
||||
class VacatedWorld(FakeWorld):
|
||||
def __init__(self):
|
||||
super().__init__(bed_id)
|
||||
self.occupancy = iter((True, False))
|
||||
|
||||
def check_bed_occupied(self, position):
|
||||
return next(self.occupancy)
|
||||
|
||||
def find_threats(self, center, distance):
|
||||
return []
|
||||
|
||||
state = SleepWithBedStates(Munch(
|
||||
time=12129, pos=(0, 64, 0), world=VacatedWorld(),
|
||||
game=FakeGame(), path=[], look_at=None, correction_count=0))
|
||||
state.area = (0, 64, 0)
|
||||
state.my_bed = True
|
||||
state.state = state.sleep_bed
|
||||
|
||||
state.sleep_bed()
|
||||
self.assertTrue(state.sleep_confirmed)
|
||||
state.sleep_bed()
|
||||
|
||||
self.assertEqual(state.state, state.break_bed)
|
||||
|
||||
def test_sleep_attempt_aborts_if_night_was_skipped_while_approaching(self):
|
||||
bed_id = next(iter(blocks.BED_IDS))
|
||||
world = FakeWorld(block=bed_id)
|
||||
|
||||
Reference in new issue
Block a user