def test_process_cycle_calls_process_simulation(self): device_mock = Mock() env = Simulation(device=device_mock) set_simulation_running(env) env._process_cycle(0.5) device_mock.assert_has_calls([call.process(0.5)]) self.assertEqual(env.cycles, 1) self.assertEqual(env.runtime, 0.5)
def test_process_calls_control_server(self): env = Simulation(device=Mock()) control_mock = Mock() env._control_server = control_mock set_simulation_running(env) env._process_cycle(0.5) control_mock.assert_has_calls([call.process()])
def test_process_cycle_calls_process_simulation(self): device_mock = Mock() env = Simulation(device=device_mock) set_simulation_running(env) env._process_cycle(0.5) device_mock.assert_has_calls( [call.process(0.5)] ) self.assertEqual(env.cycles, 1) self.assertEqual(env.runtime, 0.5)
def test_process_simulation_cycle_applies_speed(self): device_mock = Mock() env = Simulation(device=device_mock) set_simulation_running(env) env.speed = 2.0 env._process_cycle(0.5) device_mock.assert_has_calls([call.process(1.0)]) self.assertEqual(env.cycles, 1) self.assertEqual(env.runtime, 1.0)
def test_process_simulation_cycle_applies_speed(self): device_mock = Mock() env = Simulation(device=device_mock) set_simulation_running(env) env.speed = 2.0 env._process_cycle(0.5) device_mock.assert_has_calls( [call.process(1.0)]) self.assertEqual(env.cycles, 1) self.assertEqual(env.runtime, 1.0)
def test_process_cycle_calls_sleep_if_paused(self): device_mock = Mock() env = Simulation(device=device_mock) set_simulation_running(env) env.pause() # simulation paused, device should not be called env._process_cycle(0.5) device_mock.assert_not_called() env.resume() # simulation is running now, device should be called env._process_cycle(0.5) device_mock.assert_has_calls([call.process(0.5)])