Skip to content
Permalink
Browse files

Postgres provider: test default values are correctly returned

  • Loading branch information
m-kuhn committed May 23, 2015
1 parent 4358b5b commit 32463d0c15d6f03717ae2ccaa402a7cc67ecfc66
Showing with 10 additions and 3 deletions.
  1. +7 −0 tests/src/python/test_provider_postgres.py
  2. +3 −3 tests/testdata/provider/testdata.sql
@@ -14,6 +14,7 @@

import qgis
import os
from qgis.core import NULL

from qgis.core import QgsVectorLayer, QgsFeatureRequest, QgsFeature, QgsProviderRegistry
from PyQt4.QtCore import QSettings
@@ -46,5 +47,11 @@ def enableCompiler(self):
def disableCompiler(self):
QSettings().setValue(u'/qgis/postgres/compileExpressions', False)

# HERE GO THE PROVIDER SPECIFIC TESTS
def testDefaultValue(self):
assert self.provider.defaultValue(0) == u'nextval(\'qgis_test."someData_pk_seq"\'::regclass)'
assert self.provider.defaultValue(1) == NULL
assert self.provider.defaultValue(2) == '\'qgis\'::text'

if __name__ == '__main__':
unittest.main()
@@ -1,4 +1,4 @@
--
--
-- PostgreSQL database dump
--

@@ -35,9 +35,9 @@ SET default_with_oids = false;
--

CREATE TABLE "someData" (
pk integer NOT NULL,
pk SERIAL NOT NULL,
cnt integer,
name text,
name text DEFAULT 'qgis',
geom public.geometry(Point,4326)
);

0 comments on commit 32463d0

Please sign in to comment.
You can’t perform that action at this time.