Beispiel #1
0
	def test_act_pops_an_action_off_of_the_action_queue_and_if_it_is_not_possible_returns_immediately(self):  # noqa
		action = Action()
		action.is_possible = MagicMock(return_value=False)
		action.execute = MagicMock()
		u = DummyUnit()
		u.add_action(action)
		u.act(1.0)
		action.is_possible.assert_called_once_with(u, 1.0)
		action.execute.assert_not_called()
		self.assertEqual(len(u.action_queue), 0)
Beispiel #2
0
	def test_act_pops_an_action_off_of_the_action_queue_and_executes_it_and_if_it_is_not_complete_puts_it_back_to_the_front_of_the_action_queue(self):  # noqa
		action = Action()
		action.is_possible = MagicMock(return_value=True)
		action.execute = MagicMock()
		action.is_complete = MagicMock(return_value=False)
		action.finish = MagicMock()
		u = DummyUnit()
		u.add_action(action)
		u.act(1.0)
		action.is_possible.assert_called_once_with(u, 1.0)
		action.execute.assert_called_once_with(u, 1.0)
		action.is_complete.assert_called_once_with(u, 1.0)
		action.finish.assert_not_called()
		self.assertEqual(len(u.action_queue), 1)