コード例 #1
0
def test__create_flag(application, iden, has_value, flag_data, style):
    if iden.startswith("GROUP"):
        flag = _FlagLabel(flag_data)
    else:
        flag = _Flag(iden, flag_data)

    widget = InterfaceGui._create_flag(flag, [], style)

    assert isinstance(widget, QtWidgets.QWidget)
    assert widget.styleSheet() == style
    assert isinstance(widget.layout(), QtWidgets.QVBoxLayout)

    if iden.startswith("GROUP"):
        widget_top = widget.findChild(QtWidgets.QWidget,
                                      "widget_top_" + flag_data)
        assert widget.objectName() == "flag_" + flag_data
        assert widget_top.findChild(QtWidgets.QLabel, "label_" + flag_data)
    else:
        widget_top = widget.findChild(QtWidgets.QWidget, "widget_top_" + iden)
        assert widget.objectName() == "flag_" + iden
        if has_value:
            assert widget_top.findChild(QtWidgets.QLineEdit,
                                        "text_box_" + iden)
        assert widget_top.findChild(QtWidgets.QCheckBox, "check_box_" + iden)

    if 'flags' in flag_data:
        for flag_item in flag_data['flags']:
            for flag_iden in flag_item:
                if not widget.findChild(
                        QtWidgets.QWidget,
                        "flag_" + iden + NESTED_SYMBOL + flag_iden):
                    assert False
コード例 #2
0
def test__create_footer(application, btns_ref):

    btns_ref_len = len(btns_ref)
    widget = InterfaceGui._create_footer(btns_ref)
    assert len(btns_ref) == btns_ref_len + 2

    assert isinstance(widget, QtWidgets.QWidget)
    assert isinstance(widget.layout(), QtWidgets.QHBoxLayout)
    assert widget.objectName() == "widget_footer"
    assert widget.findChild(QtWidgets.QPushButton, "btn_execute")
コード例 #3
0
def test__create_value(application, iden, value_data, style):
    value = _Value(iden, value_data)

    widget = InterfaceGui._create_value(value, style)

    assert isinstance(widget, QtWidgets.QWidget)
    assert widget.styleSheet() == style
    assert isinstance(widget.layout(), QtWidgets.QHBoxLayout)
    assert widget.objectName() == "value_" + iden
    assert widget.findChild(QtWidgets.QLabel, "label_" + iden)
    assert widget.findChild(QtWidgets.QLineEdit, "text_box_" + iden)
コード例 #4
0
def test_gather_params(application, interface_command, flag_states,
                       value_states):
    interface_obj = InterfaceLoader.create_interface(
        InterfaceLoader.read_interface_file(
            "tests/stub_interfaces/interface-" + interface_command + ".yml")
    )  #get single interface object without using InterfaceLoader instance
    controller = InterfaceGuiController(interface_obj, None)
    widget = InterfaceGui(controller)

    #setup flag values
    #go through each flag_state
    for flag_iden, flag_value in flag_states.items():
        found = False
        #find qwidget with the right checkbox
        for flag_widget in controller.flag_widgets:
            if flag_widget.objectName() == "flag_" + flag_iden:
                checkbox = flag_widget.findChild(QtWidgets.QCheckBox)
                checkbox.setChecked(True)

                if flag_value:
                    textbox = flag_widget.findChild(QtWidgets.QLineEdit)
                    textbox.setText(flag_value)

                found = True
                break
        assert found  #if widget with right flag_iden not found - error

    #setup value values
    #go through each value_state
    for value_iden, value_value in value_states.items():
        found = False
        #find qwidget with the right checkbox
        for value_widget in controller.value_widgets:
            if value_widget.objectName() == "value_" + value_iden:
                textbox = value_widget.findChild(QtWidgets.QLineEdit)
                textbox.setText(value_value)

                found = True
                break
        assert found  #if widget with right value_iden not found - error

    flags, values = controller.gather_params()
    #flags
    for flag, flag_value in flag_states.items():
        assert flag in flags
        assert flag_value == flags[flag]

    #values
    for value_name, value in value_states.items():
        assert value_name in values
        assert value == value_states[value_name]
コード例 #5
0
def test_init(application, interface_loader, interface_command):

    interface = interface_loader.interfaces[interface_command]
    controller = InterfaceGuiController(interface, None)
    widget = InterfaceGui(controller)

    assert isinstance(widget, QtWidgets.QWidget)
    assert isinstance(widget.controller, InterfaceGuiController)
    assert widget.styleSheet() == widget.style
    assert widget.objectName() == "widget_interface"
    assert widget.findChild(QtWidgets.QWidget, "widget_general")
    assert widget.findChild(QtWidgets.QWidget, "widget_flags")
    assert widget.findChild(QtWidgets.QWidget, "widget_values")
コード例 #6
0
def test__create_label(application, label, object_name, text, wrap, style):

    widget = InterfaceGui._create_label(label, object_name, text, wrap, style)

    assert isinstance(widget, QtWidgets.QWidget)
    assert widget.styleSheet() == style
    assert isinstance(widget.layout(), QtWidgets.QVBoxLayout)
    assert widget.objectName() == "label_" + object_name
    assert widget.findChild(QtWidgets.QLabel, "label_" + label)
    if wrap:
        assert widget.findChild(QtWidgets.QScrollArea,
                                "label_scroll_" + object_name).findChild(
                                    QtWidgets.QLabel,
                                    "label_value_" + object_name)
    else:
        assert widget.findChild(QtWidgets.QLabel, "label_value_" + object_name)
コード例 #7
0
def test__create_general(application, category, name, version, command,
                         description, structure):

    interface = Interface(category, name, version, command, description,
                          structure)

    widget = InterfaceGui._create_general(interface)

    assert isinstance(widget, QtWidgets.QWidget)
    #style = "smth"
    # assert widget.styleSheet() == style  only if common style is used for the whole thing
    assert isinstance(widget.layout(), QtWidgets.QVBoxLayout)
    assert widget.objectName() == "widget_general"
    assert widget.findChild(QtWidgets.QWidget, "label_name")
    assert widget.findChild(QtWidgets.QWidget, "label_version")
    assert widget.findChild(QtWidgets.QWidget, "label_command")
    assert widget.findChild(QtWidgets.QWidget, "label_description")
コード例 #8
0
def test__create_values(application, values, value_widgets):

    #create values set from parameter values
    stub_values = {}
    for value_data in values:
        v = _Value(value_data, values[value_data])
        stub_values[v.iden] = v

    value_widgets_len = len(value_widgets)
    widget = InterfaceGui._create_values(stub_values, value_widgets)
    assert len(value_widgets) == value_widgets_len + len(values)

    assert isinstance(widget, QtWidgets.QWidget)
    #style = "smth"
    #assert widget.styleSheet() == style
    assert isinstance(widget.layout(), QtWidgets.QVBoxLayout)
    assert widget.objectName() == "widget_values"
    scroll = widget.findChild(QtWidgets.QScrollArea)
    for value in stub_values:
        assert scroll.findChild(QtWidgets.QWidget, "value_" + value)
コード例 #9
0
def test__create_flags(application, flags, flag_widgets):

    #create flag set from parameter values
    stub_flags = {}
    for flag_iden, flag_data in flags.items():
        if flag_iden.startswith("GROUP"):
            f = _FlagLabel(flag_data)
        else:
            f = _Flag(flag_iden, flag_data)
        stub_flags[f.iden] = f

    flag_widgets_len = len(flag_widgets)
    widget = InterfaceGui._create_flags(stub_flags, flag_widgets)
    assert len(flag_widgets) == flag_widgets_len + len(flags)

    assert isinstance(widget, QtWidgets.QWidget)
    #style = "smth"
    #assert widget.styleSheet() == style
    assert isinstance(widget.layout(), QtWidgets.QVBoxLayout)
    assert widget.objectName() == "widget_flags"
    scroll = widget.findChild(QtWidgets.QScrollArea)
    for flag in stub_flags:
        assert scroll.findChild(QtWidgets.QWidget, "flag_" + flag)