コード例 #1
0
    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)
コード例 #2
0
ファイル: test_simulation.py プロジェクト: rainfeng/lewis
    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()])
コード例 #3
0
    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)
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)])
コード例 #7
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)])