Пример #1
0
    def test_addition_emits_changed(self):
        parent = QWidget()
        widget = ReferenceDisplayWidget(parent)
        test = ModelTest()
        reference = Reference()
        test.add_reference(reference)
        model = Model()

        widget.set_item(test, model)

        detector = Mock()
        widget.changed.connect(detector.test)

        widget.dataTable.update_row_from_item(Reference())
        assert detector.test.called is True
        assert widget.content_changed is True
Пример #2
0
    def test_reference_statistics(self):
        model = Model("m1")
        ref1 = Reference()
        modeltest = ModelTest()
        modeltest.add_reference(ref1)
        ref2 = Reference()
        evidence = Evidence()
        evidence.add_reference(ref2)
        ref3 = Reference()

        model.add_reference(ref1)
        model.add_reference(ref2)
        model.add_reference(ref3)

        model.setup_tables()

        result = reference_statistics(model)
        assert result["Total"] == 3
        assert result["Unassigned"] == 1
Пример #3
0
    def test_unassigned_references(self):
        custom_proxy = ReferenceProxyFilter()
        reference = Reference()

        # Test all genes
        custom_proxy.custom_filter = 0
        assert custom_proxy.passes_custom_filter(reference) is True

        # Test unassigned
        custom_proxy.custom_filter = 1
        assert custom_proxy.passes_custom_filter(reference) is True

        # Test all filters checked
        custom_proxy.custom_filter = 2
        with pytest.raises(NotImplementedError):
            assert custom_proxy.passes_custom_filter(reference)
Пример #4
0
    def test_deletion_emits_changed(self):
        parent = QWidget()
        widget = ReferenceDisplayWidget(parent)
        test = ModelTest()
        reference = Reference()
        test.add_reference(reference)
        model = Model()

        widget.set_item(test, model)

        detector = Mock()
        widget.changed.connect(detector.test)

        widget.tableView.selectRow(0)
        QtTest.QTest.mouseClick(widget.button_del_item, QtCore.Qt.LeftButton)
        assert widget.dataTable.rowCount() == 0
        assert detector.test.called is True
        assert widget.content_changed is True
Пример #5
0
    def test_saving_items(self):

        parent = QWidget()
        widget = ReferenceDisplayWidget(parent)
        test = ModelTest()
        reference = Reference()
        test.add_reference(reference)

        model = Model()

        widget.set_item(test, model)

        new_test = ModelTest()
        widget.item = new_test

        assert len(new_test.references) == 0
        widget.save_state()
        assert len(new_test.references) == 1

        new_reference = list(new_test.references)[0]

        assert new_reference is reference