|
|
|
|
|
|
) |
|
|
|
trainer_mock.update_policy.assert_called_once() |
|
|
|
trainer_mock.increment_step.assert_called_once() |
|
|
|
|
|
|
|
|
|
|
|
def test_take_step_if_not_training(): |
|
|
|
tc, trainer_mock = trainer_controller_with_take_step_mocks() |
|
|
|
tc.train_model = False |
|
|
|
|
|
|
|
action_info_dict = {"testbrain": MagicMock()} |
|
|
|
|
|
|
|
old_step_info = EnvironmentStep(Mock(), Mock(), action_info_dict) |
|
|
|
new_step_info = EnvironmentStep(Mock(), Mock(), action_info_dict) |
|
|
|
trainer_mock.is_ready_update = MagicMock(return_value=False) |
|
|
|
|
|
|
|
env_mock = MagicMock() |
|
|
|
env_mock.step.return_value = [new_step_info] |
|
|
|
env_mock.reset.return_value = [old_step_info] |
|
|
|
|
|
|
|
tc.advance(env_mock) |
|
|
|
env_mock.reset.assert_not_called() |
|
|
|
env_mock.step.assert_called_once() |
|
|
|
trainer_mock.add_experiences.assert_called_once_with( |
|
|
|
new_step_info.previous_all_brain_info, |
|
|
|
new_step_info.current_all_brain_info, |
|
|
|
new_step_info.brain_name_to_action_info["testbrain"].outputs, |
|
|
|
) |
|
|
|
trainer_mock.process_experiences.assert_called_once_with( |
|
|
|
new_step_info.previous_all_brain_info, new_step_info.current_all_brain_info |
|
|
|
) |
|
|
|
trainer_mock.clear_update_buffer.assert_called_once() |