Beispiel #1
0
def test_UI_GIVEN_valid_command_WHEN_sending_command_THEN_command_producer_sends_command(
    qtbot, instrument, settings
):

    window = FileWriterCtrl(instrument, settings)
    qtbot.addWidget(window)
    window.command_producer = Mock()

    broker = "broker1:9092/topic1"
    service_id = "12345678"

    window.command_widget.broker_line_edit.setText(broker)
    window.command_widget.start_time_enabled.setChecked(False)
    window.command_widget.stop_time_enabled.setChecked(False)
    window.command_widget.service_id_lineedit.setText(service_id)

    window.send_command()

    window.command_producer.send_command.assert_called_once()

    sent_msg = window.command_producer.send_command.call_args_list[0][0][0]

    res = run_start_pl72.deserialise_pl72(sent_msg)

    assert res.nexus_structure
    assert "children" in res.nexus_structure
    assert res.broker == broker
    assert res.service_id == service_id
    assert not window.command_widget.ok_button.isEnabled()
def test_UI_GIVEN_valid_command_WHEN_sending_command_THEN_command_producer_sends_command(
        qtbot, instrument):

    window = FileWriterCtrl(instrument)
    qtbot.addWidget(window)
    window.command_producer = Mock()

    broker = "broker1:9092/topic1"
    service_id = "12345678"

    window.command_widget.broker_line_edit.setText(broker)
    window.command_widget.start_time_enabled.setChecked(False)
    window.command_widget.stop_time_enabled.setChecked(False)
    window.command_widget.service_id_lineedit.setText(service_id)

    window.send_command()

    window.command_producer.send_command.assert_called_once()

    sent_msg = window.command_producer.send_command.call_args_list[0][0][0]

    res = json.loads(sent_msg)

    assert res["cmd"] == "FileWriter_new"
    assert res["nexus_structure"]
    assert res["nexus_structure"]["children"]
    assert res["broker"] == broker
    assert res["service_id"] == service_id
    assert not window.command_widget.ok_button.isEnabled()