Skip to content

Commit

Permalink
Indentation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent f26f927 commit 1640906
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions tests/src/python/test_provider_mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()

Expand All @@ -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.