def test_plaintextedit(self): edit1 = QPlainTextEdit(self.parent_widget) edit1.setObjectName("field1") mapper = schema_ui_map(StringSchema, self.model, self.parent_widget) self.assertEqual(edit1.toPlainText(), "foo")
def test_boolean(self): self.model.setItem(0, 2, QStandardItem("true")) checkbox = QCheckBox(self.parent_widget) checkbox.setObjectName("field_boolean") mapper = schema_ui_map(VarietySchema, self.model, self.parent_widget) self.assertTrue(checkbox.isChecked())
def __init__(self, parent, map): QDialog.__init__(self, parent) self.map_scene = map self.setupUi(self) self.browse_icon.setEnabled(False) self.mapper = schema_ui_map(MapLayerSchema, map.layers, self) self.layers.setModel(self.map_scene.layers) self.layers.selectionModel().selectionChanged.connect( self.on_layers_selectionChanged)
def test_ints(self): item = QStandardItem("42") self.model.appendRow(item) spinner = QSpinBox(self.parent_widget) spinner.setObjectName("field_int") mapper = schema_ui_map(VarietySchema, self.model, self.parent_widget) self.assertEqual(spinner.value(), 42)
def test_mapper(self): edit1 = QLineEdit(self.parent_widget) edit1.setObjectName("field1") edit2 = QLineEdit(self.parent_widget) edit2.setObjectName("field2") mapper = schema_ui_map(StringSchema, self.model, self.parent_widget) self.assertEqual(edit1.text(), "foo") self.assertEqual(edit2.text(), "bar")
def test_mapper_labels(self): """Test out the schemamap with QLabels.""" label1 = QLabel(self.parent_widget) label1.setObjectName("field1") label2 = QLabel(self.parent_widget) label2.setObjectName("field2") mapper = schema_ui_map(StringSchema, self.model, self.parent_widget) self.assertEqual(label1.text(), "foo") self.assertEqual(label2.text(), "bar")
def test_date_label(self): datetime = QDateTime() datetime.setDate(QDate.currentDate()) self.model.setItem(0, 3, QStandardItem(datetime.toString())) label = QLabel(self.parent_widget) label.setObjectName("field_date") mapper = schema_ui_map(VarietySchema, self.model, self.parent_widget) self.assertEqual(label.text(), datetime.toString())
def test_mappedSection(self): spinner = QSpinBox(self.parent_widget) spinner.setObjectName("field_int") bad_checkbox = QCheckBox(self.parent_widget) bad_checkbox.setObjectName("field_DOES_NOT_EXIST") label = QLabel(self.parent_widget) label.setObjectName("field_date") mapper = schema_ui_map(VarietySchema, self.model, self.parent_widget) self.assertEqual(mapper.mappedSection(spinner), 0) self.assertEqual(mapper.mappedSection(label), 3) self.assertEqual(mapper.mappedSection(bad_checkbox), -1)