def test_get_flags_component():
    data_under_test = FakeInstrument([get_component()])
    under_test = ComponentTreeModel(data_under_test)

    index = under_test.createIndex(0, 0, data_under_test[0])

    assert under_test.flags(index) == (Qt.ItemIsEnabled | Qt.ItemIsSelectable)
def test_get_flags_fail():
    data_under_test = FakeInstrument([get_component()])
    under_test = ComponentTreeModel(data_under_test)

    under_test.createIndex(0, 0, data_under_test[0])

    assert under_test.flags(QModelIndex()) is Qt.NoItemFlags
def test_get_flags_component_info():
    data_under_test = FakeInstrument([get_component()])
    under_test = ComponentTreeModel(data_under_test)

    item = ComponentInfo(parent=data_under_test[0])
    index = under_test.createIndex(0, 0, item)

    assert under_test.flags(index) == Qt.ItemIsEnabled
def test_get_flags_transformation_list():
    data_under_test = FakeInstrument([get_component()])
    under_test = ComponentTreeModel(data_under_test)

    component = data_under_test[0]
    component.stored_transforms = component.transforms
    index = under_test.createIndex(0, 0, component.stored_transforms)

    assert under_test.flags(index) == Qt.ItemIsEnabled | Qt.ItemIsSelectable
def test_get_flags_other():
    data_under_test = FakeInstrument([get_component()])
    under_test = ComponentTreeModel(data_under_test)

    class TestObject:
        pass

    test_item = TestObject()
    index = under_test.createIndex(0, 0, test_item)

    assert (under_test.flags(index) == Qt.ItemIsEnabled | Qt.ItemIsSelectable
            | Qt.ItemIsEditable)