Example #1
0
    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)
Example #2
0
    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())
    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())