def test_fileoutput(self, qtbot, csv_file): csvwidget = CSVExportDialog() qtbot.addWidget(csvwidget) csvwidget.show() labels = csvwidget.findChildren(QtGui.QLabel) assert labels[0].text() == u'Output File' lineedits = csvwidget.findChildren(QtGui.QLineEdit) qtbot.keyClicks(lineedits[0], csv_file) assert csvwidget._filenameLineEdit.text() == csv_file
def test_encoding(self, qtbot): csvwidget = CSVExportDialog() qtbot.addWidget(csvwidget) csvwidget.show() comboboxes = csvwidget.findChildren(QtGui.QComboBox) comboboxes[0] assert comboboxes[0].itemText(comboboxes[0].currentIndex()) == 'UTF_8'
def test_header(self, qtbot): csvwidget = CSVExportDialog() qtbot.addWidget(csvwidget) csvwidget.show() checkboxes = csvwidget.findChildren(QtGui.QCheckBox) checkboxes[0].toggle() assert csvwidget._headerCheckBox.isChecked()
def test_accept_reject(self, qtbot): csvwidget = CSVExportDialog() qtbot.addWidget(csvwidget) csvwidget.show() buttons = csvwidget.findChildren(QtGui.QPushButton) for button in buttons: qtbot.mouseClick(button, QtCore.Qt.LeftButton) if button.text() == 'Export Data': assert csvwidget.isVisible() == True else: assert csvwidget.isVisible() == False
def test_delimiter(self, qtbot): csvwidget = CSVExportDialog() qtbot.addWidget(csvwidget) csvwidget.show() groupboxes = csvwidget.findChildren(QtGui.QGroupBox) radiobuttons = groupboxes[0].findChildren(QtGui.QRadioButton) lineedits = groupboxes[0].findChildren(QtGui.QLineEdit) delimiter = None for button in radiobuttons: qtbot.mouseClick(button, QtCore.Qt.LeftButton) if lineedits[0].isEnabled(): qtbot.keyPress(lineedits[0], ' ') assert lineedits[0].text() == '' qtbot.keyPress(lineedits[0], 'a') assert lineedits[0].text() == 'a' assert delimiter != groupboxes[0].currentSelected() delimiter = groupboxes[0].currentSelected()
def test_read_write(self, qtbot, csv_file, tmp): importWidget = CSVImportDialog() qtbot.addWidget(importWidget) importWidget.show() import_lineedits = importWidget.findChildren(QtGui.QLineEdit) qtbot.keyClicks(import_lineedits[0], csv_file) groupboxes = importWidget.findChildren(QtGui.QGroupBox) radiobuttons = groupboxes[0].findChildren(QtGui.QRadioButton) for button in radiobuttons: if button.text() == 'Semicolon': qtbot.mouseClick(button, QtCore.Qt.LeftButton) break checkboxes = importWidget.findChildren(QtGui.QCheckBox) checkboxes[0].toggle() model_in = importWidget._previewTableView.model() # convert critical datetime column: column_model = model_in.columnDtypeModel() index = column_model.index(4, 1) column_model.setData(index, 'date and time') ## # now we export the data and load it again ## exportWidget = CSVExportDialog(model_in) qtbot.addWidget(exportWidget) exportWidget.show() lineedits = exportWidget.findChildren(QtGui.QLineEdit) qtbot.keyClicks(lineedits[0], tmp) groupboxes = exportWidget.findChildren(QtGui.QGroupBox) radiobuttons = groupboxes[0].findChildren(QtGui.QRadioButton) for button in radiobuttons: if button.text() == 'Semicolon': qtbot.mouseClick(button, QtCore.Qt.LeftButton) break checkboxes = exportWidget.findChildren(QtGui.QCheckBox) checkboxes[0].toggle() buttons = exportWidget.findChildren(QtGui.QPushButton) with qtbot.waitSignal(exportWidget.exported, timeout=3000): for button in buttons: if button.text() == 'Export Data': qtbot.mouseClick(button, QtCore.Qt.LeftButton) break import_lineedits[0].clear() qtbot.keyClicks(import_lineedits[0], tmp) buttons = importWidget.findChildren(QtGui.QPushButton) with qtbot.waitSignal(importWidget.load, timeout=3000): for button in buttons: if button.text() == 'Load Data': model_out_in = importWidget._previewTableView.model() qtbot.mouseClick(button, QtCore.Qt.LeftButton) break column_model = model_out_in.columnDtypeModel() index = column_model.index(4, 1) column_model.setData(index, 'date and time') comparator = model_in.dataFrame() == model_out_in.dataFrame() assert all(comparator) df = model_out_in.dataFrame()