Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
	def test_execute_calls__execute_and_adds_dt_to_elapsed_time(self, mock__execute):  # noqa
		action = Action()
		action.execute('dummy_unit', 1.5)
		mock__execute.assert_called_once_with('dummy_unit', 1.5)
		self.assertEqual(action.elapsed_time, 1.5)