def test_get_component_parent(): data_under_test = FakeInstrument([get_component()]) under_test = ComponentTreeModel(data_under_test) test_index = under_test.createIndex(0, 0, data_under_test[0]) assert under_test.parent(test_index) == QModelIndex()
def test_get_default_parent(): data_under_test = FakeInstrument() under_test = ComponentTreeModel(data_under_test) test_index = QModelIndex() assert under_test.parent(test_index) == QModelIndex()
def test_get_component_info_parent(): data_under_test = FakeInstrument([get_component()]) under_test = ComponentTreeModel(data_under_test) # Creating ComponentInfo in-line causes a segmentation error temp_component_info = ComponentInfo(parent=data_under_test[0]) test_index = under_test.createIndex(0, 0, temp_component_info) assert under_test.parent( test_index).internalPointer() is data_under_test[0]
def expand_transformation_list( node: QModelIndex, component_tree_view: QTreeView, component_model: ComponentTreeModel, ): current_pointer = node.internalPointer() if isinstance(current_pointer, TransformationsList) or isinstance( current_pointer, Component): component_tree_view.expand(node) if isinstance(current_pointer, Component): trans_list_index = component_model.index(1, 0, node) component_tree_view.expand(trans_list_index) else: component_index = component_model.parent(node) component_tree_view.expand(component_index) elif isinstance(current_pointer, Transformation): trans_list_index = component_model.parent(node) component_tree_view.expand(trans_list_index) component_index = component_model.parent(trans_list_index) component_tree_view.expand(component_index)
def test_get_transform_list_parent(): data_under_test = FakeInstrument([get_component()]) under_test = ComponentTreeModel(data_under_test) data_under_test[0].stored_transforms = data_under_test[0].transforms test_index = under_test.createIndex(0, 0, data_under_test[0].stored_transforms) temp_parent = under_test.parent(test_index) assert temp_parent.internalPointer() is data_under_test[0] assert temp_parent.row() == 0
def test_get_transformation_link_parent(): component = get_component() data_under_test = FakeInstrument([component]) component.stored_transforms = component.transforms transform_link = LinkTransformation(component.stored_transforms) component.stored_transforms.link = transform_link component.stored_transforms.has_link = True under_test = ComponentTreeModel(data_under_test) test_index = under_test.createIndex(0, 0, transform_link) found_parent = under_test.parent(test_index) assert found_parent.internalPointer( ) == data_under_test[0].stored_transforms assert found_parent.row() == 1
def test_get_transformation_parent(): component = get_component() translation = component.add_translation(QVector3D(1.0, 0.0, 0.0)) component.depends_on = translation data_under_test = FakeInstrument([component]) component.stored_transforms = component.transforms translation.parent = component.stored_transforms under_test = ComponentTreeModel(data_under_test) test_index = under_test.createIndex(0, 0, translation) found_parent = under_test.parent(test_index) assert found_parent.internalPointer( ) == data_under_test[0].stored_transforms assert found_parent.row() == 1