Skip to content
Permalink
Browse files
Add diagrams to tests
  • Loading branch information
rduivenvoorde authored and nyalldawson committed Sep 8, 2021
1 parent 30ae071 commit ecf9147df569c7438175adec3b5f4212571abae6
Showing with 57 additions and 2 deletions.
  1. +57 −2 tests/src/python/test_qgsvectorlayertemporalproperties.py
@@ -277,6 +277,17 @@ def testSingleFieldMode(self):

# since 3.22 there is also the option to include the end of the feature event
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
# map range [-------------------------)
# feature ranges . . [-------] (false)
# . [-------] (false)
# . [---.---] (true)
# . [-------] . (true)
# [-------] . (true)
# [---.---] . (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')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

@@ -473,8 +484,18 @@ def testDualFieldMode(self):
range = QgsDateTimeRange(QDateTime(QDate(2019, 3, 4), QTime(11, 12, 13)), QDateTime(QDate(2020, 5, 6), QTime(8, 9, 10)), includeEnd=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)')
# since 3.22 there is also the option to include the end of the feature event
# => start of feature < end of range AND end of feature >= start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
# map range [-------------------------)
# feature ranges . . [-------] (false)
# . [-------] (false)
# . [---.---] (true)
# . [-------] . (true)
# [-------] . (true)
# [---.---] . (true)
# [-------] . (true)
# [-------] . . (false)
#
# => start of feature < end of range AND end of feature >= start of range
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)')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

@@ -577,6 +598,14 @@ def testDualFieldMode(self):
# since 3.22 there is also the option to include the end of the feature event
# => end of feature >= start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
# map range [-------------------------)
# feature ranges --------.-------------------------.---------] (true)
# --------.-------------------------] (true)
# --------.--------------------] . (true)
# --------] . (true)
# -----] . (false)
#
# => 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')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

@@ -663,6 +692,16 @@ def testStartAndDurationMode(self):
# => start of feature < end of range AND start + duration > start of range
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)')
# map range [-------------------------)
# feature ranges . . [-------] (false)
# . [-------] (true)
# . [---.---] (true)
# . [-------] . (true)
# [-------] . (true)
# [---.---] . (true)
# [-------] . (true)
# [-------] . . (false)
#
# => start of feature <= end of range AND start + duration > start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
self.assertEqual(props.createFilterString(context, range),
@@ -781,6 +820,16 @@ 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))')
# map range [-------------------------)
# feature ranges . . [-------] (false)
# . [-------] (false)
# . [---.---] (true)
# . [-------] . (true)
# [-------] . (true)
# [---.---] . (true)
# [-------] . (true)
# [-------] . . (false)
#
# => 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))')
@@ -881,7 +930,13 @@ 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)')
# => end of feature >= start of range
# map range [-------------------------)
# feature ranges --------.-------------------------.---------] (true)
# --------.-------------------------] (true)
# --------.--------------------] . (true)
# --------] . (true)
# -----] . (false)
# # => end of feature >= start of range
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginIncludeEnd)
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)')
props.setLimitMode(QgsVectorLayerTemporalProperties.LimitMode.ModeIncludeBeginExcludeEnd) # back to default

0 comments on commit ecf9147

Please sign in to comment.