def check_attributes(table):
    """
    Checks output attributes conform to OWFile expectations
    Keys "Name" and "Description" must be strings, etc
    This should be added to tests for all readers that implement attributes
    """
    OWFile._describe(table)
Beispiel #2
0
 def test_report(self):
     count = 5
     for i in range(count):
         rep = OWReport.get_instance()
         file = OWFile()
         file.create_report_html()
         rep.make_report(file)
     self.assertEqual(rep.table_model.rowCount(), count)
Beispiel #3
0
 def test_report(self):
     count = 5
     for i in range(count):
         rep = OWReport.get_instance()
         file = OWFile()
         file.create_report_html()
         rep.make_report(file)
     self.assertEqual(rep.table_model.rowCount(), count)
Beispiel #4
0
class TestOWFile(GuiTest):
    def setUp(self):
        self.widget = OWFile()
        self.event_data = None

    def test_dragEnterEvent_accepts_urls(self):
        event = self._drag_enter_event(TITANIC_URL)
        self.widget.dragEnterEvent(event)
        self.assertTrue(event.isAccepted())

    def test_dragEnterEvent_skips_osx_file_references(self):
        event = self._drag_enter_event('/.file/id=12345')
        self.widget.dragEnterEvent(event)
        self.assertFalse(event.isAccepted())

    def test_dragEnterEvent_skips_usupported_files(self):
        event = self._drag_enter_event('file.unsupported')
        self.widget.dragEnterEvent(event)
        self.assertFalse(event.isAccepted())

    def _drag_enter_event(self, url):
        # make sure data does not get garbage collected before it used
        self.event_data = data = QMimeData()
        data.setUrls([QUrl(url)])
        return QDragEnterEvent(
            QPoint(0, 0), Qt.MoveAction, data,
            Qt.NoButton, Qt.NoModifier)

    def test_dropEvent_selects_file(self):
        self.widget.load_data = Mock()
        self.widget.source = OWFile.URL

        event = self._drop_event(TITANIC_URL)
        self.widget.dropEvent(event)

        self.assertEqual(self.widget.source, OWFile.LOCAL_FILE)
        self.assertEqual(self.widget.last_path(), TITANIC_URL)
        self.widget.load_data.assert_called_with()

    def _drop_event(self, url):
        # make sure data does not get garbage collected before it used
        self.event_data = data = QMimeData()
        data.setUrls([QUrl(url)])

        return QDropEvent(
            QPoint(0, 0), Qt.MoveAction, data,
            Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)
Beispiel #5
0
class TestOWFile(GuiTest):
    def setUp(self):
        self.widget = OWFile()
        self.event_data = None

    def test_dragEnterEvent_accepts_urls(self):
        event = self._drag_enter_event(TITANIC_URL)
        self.widget.dragEnterEvent(event)
        self.assertTrue(event.isAccepted())

    def test_dragEnterEvent_skips_osx_file_references(self):
        event = self._drag_enter_event('/.file/id=12345')
        self.widget.dragEnterEvent(event)
        self.assertFalse(event.isAccepted())

    def test_dragEnterEvent_skips_usupported_files(self):
        event = self._drag_enter_event('file.unsupported')
        self.widget.dragEnterEvent(event)
        self.assertFalse(event.isAccepted())

    def _drag_enter_event(self, url):
        # make sure data does not get garbage collected before it used
        self.event_data = data = QMimeData()
        data.setUrls([QUrl(url)])
        return QDragEnterEvent(QPoint(0, 0), Qt.MoveAction, data, Qt.NoButton,
                               Qt.NoModifier)

    def test_dropEvent_selects_file(self):
        self.widget.load_data = Mock()
        self.widget.source = OWFile.URL

        event = self._drop_event(TITANIC_URL)
        self.widget.dropEvent(event)

        self.assertEqual(self.widget.source, OWFile.LOCAL_FILE)
        self.assertEqual(self.widget.last_path(), TITANIC_URL)
        self.widget.load_data.assert_called_with()

    def _drop_event(self, url):
        # make sure data does not get garbage collected before it used
        self.event_data = data = QMimeData()
        data.setUrls([QUrl(url)])

        return QDropEvent(QPoint(0, 0), Qt.MoveAction, data, Qt.NoButton,
                          Qt.NoModifier, QDropEvent.Drop)
Beispiel #6
0
 def setUp(self):
     self.widget = OWFile()
     self.event_data = None
                return widget


if __name__ == "__main__":
    import sys
    from Orange.data import Table
    from Orange.widgets.data.owfile import OWFile
    from Orange.widgets.data.owtable import OWDataTable
    from Orange.widgets.data.owdiscretize import OWDiscretize
    from Orange.widgets.model.owrandomforest import OWRandomForest

    iris = Table("iris")
    app = QApplication(sys.argv)

    main = OWReport.get_instance()
    file = OWFile()
    file.create_report_html()
    main.make_report(file)

    table = OWDataTable()
    table.set_dataset(iris)
    table.create_report_html()
    main.make_report(table)

    main = OWReport.get_instance()
    disc = OWDiscretize()
    disc.create_report_html()
    main.make_report(disc)

    learner = OWRandomForest()
    learner.create_report_html()
Beispiel #8
0
                return widget


if __name__ == "__main__":
    import sys
    from Orange.data import Table
    from Orange.widgets.data.owfile import OWFile
    from Orange.widgets.data.owtable import OWDataTable
    from Orange.widgets.data.owdiscretize import OWDiscretize
    from Orange.widgets.model.owrandomforest import OWRandomForest

    iris = Table("iris")
    app = QApplication(sys.argv)

    main = OWReport.get_instance()
    file = OWFile()
    file.create_report_html()
    main.make_report(file)

    table = OWDataTable()
    table.set_dataset(iris)
    table.create_report_html()
    main.make_report(table)

    main = OWReport.get_instance()
    disc = OWDiscretize()
    disc.create_report_html()
    main.make_report(disc)

    learner = OWRandomForest()
    learner.create_report_html()
Beispiel #9
0
 def setUp(self):
     self.widget = OWFile()
     self.event_data = None