Skip to content
Permalink
Browse files

More oracle test fixes

  • Loading branch information
nyalldawson committed May 14, 2020
1 parent a08bdc8 commit 242973a649b5f543ceb49f2b2af70c40e0931169
Showing with 35 additions and 17 deletions.
  1. +35 −17 tests/src/python/providertestbase.py
@@ -351,14 +351,16 @@ def testMinValue(self):
if self.treat_datetime_as_string():
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('dt')), '2020-05-03 12:13:14')
else:
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('dt')), QDateTime(QDate(2020, 5, 3), QTime(12, 13, 14)))
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('dt')),
QDateTime(QDate(2020, 5, 3), QTime(12, 13, 14)))

if self.treat_date_as_string():
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('date')), '2020-05-02')
elif not self.treat_date_as_datetime():
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('date')), QDate(2020, 5, 2))
else:
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('date')), QDateTime(2020, 5, 2, 0, 0, 0))
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('date')),
QDateTime(2020, 5, 2, 0, 0, 0))

if not self.treat_time_as_string():
self.assertEqual(self.source.minimumValue(self.source.fields().lookupField('time')), QTime(12, 13, 1))
@@ -379,7 +381,8 @@ def testMaxValue(self):
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('name')), 'Pear')

if not self.treat_datetime_as_string():
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('dt')), QDateTime(QDate(2021, 5, 4), QTime(13, 13, 14)))
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('dt')),
QDateTime(QDate(2021, 5, 4), QTime(13, 13, 14)))
else:
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('dt')), '2021-05-04 13:13:14')

@@ -388,7 +391,8 @@ def testMaxValue(self):
elif not self.treat_date_as_datetime():
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('date')), QDate(2021, 5, 4))
else:
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('date')), QDateTime(2021, 5, 4, 0, 0, 0))
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('date')),
QDateTime(2021, 5, 4, 0, 0, 0))

if not self.treat_time_as_string():
self.assertEqual(self.source.maximumValue(self.source.fields().lookupField('time')), QTime(13, 13, 14))
@@ -447,17 +451,20 @@ def testUnique(self):

if self.treat_datetime_as_string():
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('dt'))),
set(['2021-05-04 13:13:14', '2020-05-04 12:14:14', '2020-05-04 12:13:14', '2020-05-03 12:13:14', NULL]))
set(['2021-05-04 13:13:14', '2020-05-04 12:14:14', '2020-05-04 12:13:14',
'2020-05-03 12:13:14', NULL]))
else:
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('dt'))),
set([QDateTime(2021, 5, 4, 13, 13, 14), QDateTime(2020, 5, 4, 12, 14, 14), QDateTime(2020, 5, 4, 12, 13, 14), QDateTime(2020, 5, 3, 12, 13, 14), NULL]))
set([QDateTime(2021, 5, 4, 13, 13, 14), QDateTime(2020, 5, 4, 12, 14, 14),
QDateTime(2020, 5, 4, 12, 13, 14), QDateTime(2020, 5, 3, 12, 13, 14), NULL]))

if self.treat_date_as_string():
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('date'))),
set(['2020-05-03', '2020-05-04', '2021-05-04', '2020-05-02', NULL]))
elif self.treat_date_as_datetime():
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('date'))),
set([QDateTime(2020, 5, 3, 0, 0, 0), QDateTime(2020, 5, 4, 0, 0, 0), QDateTime(2021, 5, 4, 0, 0, 0), QDateTime(2020, 5, 2, 0, 0, 0), NULL]))
set([QDateTime(2020, 5, 3, 0, 0, 0), QDateTime(2020, 5, 4, 0, 0, 0),
QDateTime(2021, 5, 4, 0, 0, 0), QDateTime(2020, 5, 2, 0, 0, 0), NULL]))
else:
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('date'))),
set([QDate(2020, 5, 3), QDate(2020, 5, 4), QDate(2021, 5, 4), QDate(2020, 5, 2), NULL]))
@@ -583,14 +590,20 @@ def testAddFeature(self):
self.assertTrue(l.isValid())

f1 = QgsFeature()
f1.setAttributes([6, -220, NULL, 'String', '15', '2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDate(2019, 1, 2),
f1.setAttributes([6, -220, NULL, 'String', '15',
'2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDateTime(2019, 1, 2, 0, 0,
0) if self.treat_date_as_datetime() else QDate(
2019, 1, 2),
'03:04:05' if self.treat_time_as_string() else QTime(3, 4, 5)])
f1.setGeometry(QgsGeometry.fromWkt('Point (-72.345 71.987)'))

f2 = QgsFeature()
f2.setAttributes([7, 330, 'Coconut', 'CoCoNut', '13', '2018-05-06 07:08:09' if self.treat_datetime_as_string() else QDateTime(2018, 5, 6, 7, 8, 9),
'2018-05-06' if self.treat_date_as_string() else QDate(2018, 5, 6),
f2.setAttributes([7, 330, 'Coconut', 'CoCoNut', '13',
'2018-05-06 07:08:09' if self.treat_datetime_as_string() else QDateTime(2018, 5, 6, 7, 8, 9),
'2018-05-06' if self.treat_date_as_string() else QDateTime(2018, 5, 6, 0, 0,
0) if self.treat_date_as_datetime() else QDate(
2018, 5, 6),
'07:08:09' if self.treat_time_as_string() else QTime(7, 8, 9)])

if l.dataProvider().capabilities() & QgsVectorDataProvider.AddFeatures:
@@ -627,7 +640,10 @@ def testAddFeatureFastInsert(self):
self.assertTrue(l.isValid())

f1 = QgsFeature()
f1.setAttributes([6, -220, NULL, 'String', '15', QDateTime(2019, 1, 2, 3, 4, 5), QDate(2019, 1, 2), QTime(3, 4, 5)])
f1.setAttributes(
[6, -220, NULL, 'String', '15',
'2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5), '2019-01-02' if self.treat_date_as_string() else QDateTime(2019, 1, 2, 0, 0, 0) if self.treat_date_as_datetime() else QDate(2019, 1, 2),
'03:04:05' if self.treat_time_as_string() else QTime(3, 4, 5)])
f1.setGeometry(QgsGeometry.fromWkt('Point (-72.345 71.987)'))

f2 = QgsFeature()
@@ -680,12 +696,14 @@ def testAddFeatureExtraAttributes(self):
# test that adding features with too many attributes drops these attributes
# we be more tricky and also add a valid feature to stress test the provider
f1 = QgsFeature()
f1.setAttributes([6, -220, NULL, 'String', '15', '2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDate(2019, 1, 2),
f1.setAttributes([6, -220, NULL, 'String', '15',
'2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDateTime(2019, 1, 2, 0, 0, 0) if self.treat_date_as_datetime() else QDate(2019, 1, 2),
'03:04:05' if self.treat_time_as_string() else QTime(3, 4, 5)])
f2 = QgsFeature()
f2.setAttributes([7, -230, NULL, 'String', '15', '2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDate(2019, 1, 2),
f2.setAttributes([7, -230, NULL, 'String', '15',
'2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDateTime(2019, 1, 2, 0, 0, 0) if self.treat_date_as_datetime() else QDate(2019, 1, 2),
'03:04:05' if self.treat_time_as_string() else QTime(3, 4, 5), 15, 16, 17])

result, added = l.dataProvider().addFeatures([f1, f2])
@@ -697,7 +715,7 @@ def testAddFeatureExtraAttributes(self):
self.assertEqual(added.attributes(), [7, -230, NULL, 'String', '15',
'2019-01-02 03:04:05' if self.treat_datetime_as_string() else QDateTime(
2019, 1, 2, 3, 4, 5),
'2019-01-02' if self.treat_date_as_string() else QDate(2019, 1, 2),
'2019-01-02' if self.treat_date_as_string() else QDateTime(2019, 1, 2, 0, 0, 0) if self.treat_date_as_datetime() else QDate(2019, 1, 2),
'03:04:05' if self.treat_time_as_string() else QTime(3, 4, 5)])

def testAddFeatureWrongGeomType(self):

0 comments on commit 242973a

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