Skip to content
Permalink
Browse files
Fix tests according to fixed logic
  • Loading branch information
rduivenvoorde authored and nyalldawson committed Sep 8, 2021
1 parent 25fe932 commit 7f2ab1233e76a1b647bf95177015b6f38f290383
Showing with 14 additions and 14 deletions.
  1. +14 −14 tests/src/python/test_qgsvectorlayertemporalproperties.py
@@ -258,7 +258,7 @@ def testSingleFieldMode(self):
# OR start of feature <= end of range AND start of feature > start of range - duration
self.assertEqual(props.createFilterString(context, range), '("start_field" > make_datetime(2019,3,1,11,12,13) AND "start_field" <= make_datetime(2020,5,6,8,9,10)) OR "start_field" IS NULL')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
# and the temporal properties exactly the same
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
@@ -286,9 +286,9 @@ def testSingleFieldMode(self):
# [---.---] . (true)
# [-------] . (true)
# [-------] . . (false)
# => start of feature < end of range AND start of feature + duration > start of range
# OR start of feature <= end of range AND start of feature > start of range - duration
self.assertEqual(props.createFilterString(context, range), '("start_field" > make_datetime(2019,3,1,11,12,13) AND "start_field" <= make_datetime(2020,5,6,8,9,10)) OR "start_field" IS NULL')
# => start of feature < end of range AND start of feature + duration >= start of range
# OR start of feature < end of range AND start of feature >= start of range - duration
self.assertEqual(props.createFilterString(context, range), '("start_field" >= make_datetime(2019,3,1,11,12,13) AND "start_field" < make_datetime(2020,5,6,8,9,10)) OR "start_field" IS NULL')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

# different unit
@@ -469,7 +469,7 @@ def testDualFieldMode(self):
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeBeginning=False)
self.assertEqual(props.createFilterString(context, range), '("start_field" <= make_datetime(2020,5,6,8,9,10) OR "start_field" IS NULL) AND ("end_field" > make_datetime(2019,3,4,11,12,13) OR "end_field" IS NULL)')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
# map range [-------------------------)
# feature ranges . . [-------) (false)
# . [-------) (false)
@@ -535,7 +535,7 @@ def testDualFieldMode(self):
# => start of feature <= end of range
self.assertEqual(props.createFilterString(context, range), '"start_field" <= make_datetime(2020,5,6,8,9,10) OR "start_field" IS NULL')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
# feature ranges . . [--------> (false)
@@ -584,7 +584,7 @@ def testDualFieldMode(self):
# => end of feature > start of range
self.assertEqual(props.createFilterString(context, range), '"end_field" > make_datetime(2019,3,4,11,12,13) OR "end_field" IS NULL')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
# feature ranges --------.-------------------------.---------) (true)
@@ -676,7 +676,7 @@ def testStartAndDurationMode(self):
self.assertEqual(props.createFilterString(context, range),
'("start_field" <= make_datetime(2020,5,6,8,9,10) OR "start_field" IS NULL) AND (("start_field" + make_interval(0,0,0,0,0,0,"duration"/1000) > make_datetime(2019,3,4,11,12,13)) OR "duration" IS NULL)')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)),
QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
@@ -702,10 +702,10 @@ def testStartAndDurationMode(self):
# [-------] . (true)
# [-------] . . (false)
#
# => start of feature <= end of range AND start + duration > start of range
# => start of feature < end of range AND start + duration >= start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
self.assertEqual(props.createFilterString(context, range),
'("start_field" <= make_datetime(2020,5,6,8,9,10) OR "start_field" IS NULL) AND (("start_field" + make_interval(0,0,0,0,0,0,"duration"/1000) > make_datetime(2019,3,4,11,12,13)) OR "duration" IS NULL)')
'("start_field" < make_datetime(2020,5,6,8,9,10) OR "start_field" IS NULL) AND (("start_field" + make_interval(0,0,0,0,0,0,"duration"/1000) >= make_datetime(2019,3,4,11,12,13)) OR "duration" IS NULL)')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

# different units
@@ -806,7 +806,7 @@ def testExpressionMode(self):
# => start expression <= end of range AND end expression > start of range
self.assertEqual(props.createFilterString(context, range), '((to_datetime("my string field", \'yyyy MM dd hh::mm:ss\')") <= make_datetime(2020,5,6,8,9,10)) AND ((to_datetime("my end field", \'yyyy MM dd hh::mm:ss\')") > make_datetime(2019,3,4,11,12,13))')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
# feature ranges . . [-------) (false)
@@ -830,9 +830,9 @@ def testExpressionMode(self):
# [-------] . (true)
# [-------] . . (false)
#
# => start expression <= end of range AND end expression > start of range
# => start expression < end of range AND end expression >= start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
self.assertEqual(props.createFilterString(context, range), '((to_datetime("my string field", \'yyyy MM dd hh::mm:ss\')") <= make_datetime(2020,5,6,8,9,10)) AND ((to_datetime("my end field", \'yyyy MM dd hh::mm:ss\')") > make_datetime(2019,3,4,11,12,13))')
self.assertEqual(props.createFilterString(context, range), '((to_datetime("my string field", \'yyyy MM dd hh::mm:ss\')") < make_datetime(2020,5,6,8,9,10)) AND ((to_datetime("my end field", \'yyyy MM dd hh::mm:ss\')") >= make_datetime(2019,3,4,11,12,13))')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

# features go to +eternity
@@ -919,7 +919,7 @@ def testExpressionMode(self):
# => end of feature > start of range
self.assertEqual(props.createFilterString(context, range), '(to_datetime("my end field", \'yyyy MM dd hh::mm:ss\')") > make_datetime(2019,3,4,11,12,13)')

# THIS is the QGIS default: using a range with includeBeginning=true en includeEnd=false
# THIS is the QGIS default: using a range with includeBeginning=true and includeEnd=false
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=False)
# map range [-------------------------)
# feature ranges --------.-------------------------.---------) (true)

0 comments on commit 7f2ab12

Please sign in to comment.