Skip to content
Permalink
Browse files

Indentation fix

  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent f26f927 commit 164090688e7818b8df472d618fcb9cfb0c2978b6
Showing with 17 additions and 10 deletions.
  1. +17 −10 tests/src/python/test_provider_mssql.py
@@ -50,14 +50,16 @@ def setUpClass(cls):
"""Run before all tests"""
cls.dbconn=u"dbname='gis' host=localhost\sqlexpress"
if 'QGIS_MSSQLTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_MSSQLTEST_DB']
cls.dbconn=os.environ['QGIS_MSSQLTEST_DB']
# Create test layers
cls.vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POINT table="qgis_test"."someData" (geom) sql=', 'test', 'mssql')
cls.vl=QgsVectorLayer(
cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POINT table="qgis_test"."someData" (geom) sql=', 'test', 'mssql')
assert(cls.vl.isValid())
cls.provider = cls.vl.dataProvider()
cls.poly_vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'mssql')
cls.provider=cls.vl.dataProvider()
cls.poly_vl=QgsVectorLayer(
cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'mssql')
assert(cls.poly_vl.isValid())
cls.poly_provider = cls.poly_vl.dataProvider()
cls.poly_provider=cls.poly_vl.dataProvider()

@classmethod
def tearDownClass(cls):
@@ -71,13 +73,17 @@ def disableCompiler(self):

# HERE GO THE PROVIDER SPECIFIC TESTS
def testDateTimeTypes(self):
vl=QgsVectorLayer('%s table="qgis_test"."date_times" sql=' % (self.dbconn), "testdatetimes", "mssql")
vl=QgsVectorLayer('%s table="qgis_test"."date_times" sql=' %
(self.dbconn), "testdatetimes", "mssql")
assert(vl.isValid())

fields=vl.dataProvider().fields()
self.assertEqual(fields.at(fields.indexFromName('date_field')).type(), QVariant.Date)
self.assertEqual(fields.at(fields.indexFromName('time_field')).type(), QVariant.Time)
self.assertEqual(fields.at(fields.indexFromName('datetime_field')).type(), QVariant.DateTime)
self.assertEqual(fields.at(fields.indexFromName(
'date_field')).type(), QVariant.Date)
self.assertEqual(fields.at(fields.indexFromName(
'time_field')).type(), QVariant.Time)
self.assertEqual(fields.at(fields.indexFromName(
'datetime_field')).type(), QVariant.DateTime)

f=vl.getFeatures(QgsFeatureRequest()).next()

@@ -89,7 +95,8 @@ def testDateTimeTypes(self):
self.assertEqual(f.attributes()[time_idx], QTime(13, 41, 52))
datetime_idx=vl.fieldNameIndex('datetime_field')
assert isinstance(f.attributes()[datetime_idx], QDateTime)
self.assertEqual(f.attributes()[datetime_idx], QDateTime(QDate(2004, 3, 4), QTime(13, 41, 52)))
self.assertEqual(f.attributes()[datetime_idx], QDateTime(
QDate(2004, 3, 4), QTime(13, 41, 52)))

if __name__ == '__main__':
unittest.main()

0 comments on commit 1640906

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