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
def test_set_speed(): """Test set_speed""" bs_client_mock = mock.Mock() bs_sim_controls = BlueSkySimulatorControls(bs_client_mock) bs_client_mock.send_stack_cmd.return_value = "Error" err = bs_sim_controls.set_speed(1.23) assert err == 'No confirmation received from BlueSky. Received: "Error"' bs_client_mock.reset_mock() dt_mult = 10.1 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.send_stack_cmd.assert_called_once_with( f"DTMULT {dt_mult}", response_expected=True)