コード例 #1
0
def test_reset():
    """Test reset"""

    bs_client_mock = mock.Mock()
    bs_sim_controls = BlueSkySimulatorControls(bs_client_mock)

    bs_client_mock.reset_sim.return_value = "Error"
    err = bs_sim_controls.reset()
    assert err == "Error"

    bs_client_mock.reset_mock()
    bs_client_mock.reset_sim.return_value = None
    err = bs_sim_controls.reset()
    assert not err
    bs_client_mock.reset_sim.assert_called_once()
コード例 #2
0
def test_dt_mult_handling():
    """
    Tests that we properly track the dtmult value. BlueSky resets this value to 1 after
    a reset. We can't query for the current value however, so have to track it ourselves
    """

    bs_client_mock = mock.Mock()
    bs_sim_controls = BlueSkySimulatorControls(bs_client_mock)

    dt_mult = 4
    bs_client_mock.send_stack_cmd.return_value = [f"Speed set to {dt_mult}"]
    err = bs_sim_controls.set_speed(dt_mult)
    assert not err

    bs_client_mock.sim_info_stream_data = _TEST_SIMINFO

    with mock.patch(
        "bluebird.sim_client.bluesky.bluesky_simulator_controls.in_agent_mode"
    ) as in_agent_mode_mock:

        in_agent_mode_mock.return_value = True

        props = bs_sim_controls.properties
        assert props.speed == dt_mult

        bs_client_mock.reset_sim.return_value = None
        err = bs_sim_controls.reset()
        assert not err

        props = bs_sim_controls.properties
        assert props.speed == 1