Lock farming pitch downward
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
|
||||
from munch import Munch
|
||||
|
||||
from mosfet.bot import FARMING_PITCH, pitch_lock_for_job, update_pitch
|
||||
|
||||
|
||||
class TestFarmingPitch(unittest.TestCase):
|
||||
def test_only_crop_farming_locks_pitch(self):
|
||||
def farm_crop():
|
||||
pass
|
||||
|
||||
def sleep():
|
||||
pass
|
||||
|
||||
self.assertEqual(
|
||||
pitch_lock_for_job(Munch(state=farm_crop)), FARMING_PITCH)
|
||||
self.assertIsNone(pitch_lock_for_job(Munch(state=sleep)))
|
||||
self.assertIsNone(pitch_lock_for_job(None))
|
||||
|
||||
def test_pitch_is_held_at_45_despite_look_target_changes(self):
|
||||
state = Munch(pitch=0.0)
|
||||
for _ in range(5):
|
||||
update_pitch(state, object(), FARMING_PITCH)
|
||||
self.assertEqual(state.pitch, 45.0)
|
||||
|
||||
# Without the farming lock, ordinary look behavior is restored.
|
||||
update_pitch(state, None)
|
||||
self.assertEqual(state.pitch, 35.0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user