def testGettersSetters(self): """ test model getters/setters """ l = create_layer() m = QgsFieldModel() self.assertFalse(m.layer()) m.setLayer(l) self.assertEqual(m.layer(), l) m.setAllowExpression(True) self.assertTrue(m.allowExpression()) m.setAllowExpression(False) self.assertFalse(m.allowExpression()) m.setAllowEmptyFieldName(True) self.assertTrue(m.allowEmptyFieldName()) m.setAllowEmptyFieldName(False) self.assertFalse(m.allowEmptyFieldName()) fields = QgsFields() fields.append(QgsField('test1', QVariant.String)) fields.append(QgsField('test2', QVariant.String)) m.setFields(fields) self.assertIsNone(m.layer()) self.assertEqual(m.fields(), fields)
def testGettersSetters(self): """ test model getters/setters """ l = create_layer() m = QgsFieldModel() self.assertFalse(m.layer()) m.setLayer(l) self.assertEqual(m.layer(), l) m.setAllowExpression(True) self.assertTrue(m.allowExpression()) m.setAllowExpression(False) self.assertFalse(m.allowExpression()) m.setAllowEmptyFieldName(True) self.assertTrue(m.allowEmptyFieldName()) m.setAllowEmptyFieldName(False) self.assertFalse(m.allowEmptyFieldName())