def testEventDataCumulativeAggregation(self):

        s3db = current.s3db

        assertEqual = self.assertEqual
        assertTrue = self.assertTrue

        PERIODS = "p"
        TIMES = "t"
        VALUE = "v"

        resource = s3db.resource("tp_test_events")
        ts = S3TimeSeries(resource,
                          event_start = "event_start",
                          event_end = "event_end",
                          start = "2012-01-01",
                          end = "2013-01-01",
                          slots = "months",
                          facts = [S3TimeSeriesFact("cumulate",
                                                    None,
                                                    slope="parameter1",
                                                    interval="months",
                                                    )
                                   ],
                          )

        # Verify correct slot length
        assertEqual(ts.event_frame.slots, "months")

        expected = [
            ((2012,1,1), (2012,2,1), [45]),       # 01 P NS1 NS2 NS3 (SE1 SE2 SE3)
            ((2012,2,1), (2012,3,1), [45]),       # 02 P NS1 NS2 NS3 (SE1 SE2 SE3)
            ((2012,3,1), (2012,4,1), [45]),       # 03 P NS2 NS3 (SE1 SE2 SE3)
            ((2012,4,1), (2012,5,1), [45]),       # 04 P NS2 NS3 (SE1 SE2 SE3)
            ((2012,5,1), (2012,6,1), [45]),       # 05 P NS2 NS3 (SE1 SE2 SE3)
            ((2012,6,1), (2012,7,1), [45]),       # 06 P NS3 (SE1 SE2 SE3)
            ((2012,7,1), (2012,8,1), [48]),       # 07 P NS3 (SE1 SE2 SE3) NE1
            ((2012,8,1), (2012,9,1), [51]),       # 08 P NS3 (SE1 SE2 SE3) NE1
            ((2012,9,1), (2012,10,1), [54]),      # 09 P (SE1 SE2 SE3) NE1
            ((2012,10,1), (2012,11,1), [60]),     # 10 P (SE1 SE2 SE3) NE1 NE2
            ((2012,11,1), (2012,12,1), [66]),     # 11 P (SE1 SE2 SE3) NE1 NE2
            ((2012,12,1), (2013,1,1), [72]),      # 12 P (SE1 SE2 SE3) NE1 NE2
        ]

        result = ts.as_dict()
        periods = result[PERIODS]

        for i, period in enumerate(periods):

            expected_start, expected_end, expected_value = expected[i]
            expected_start = tp_datetime(*expected_start).isoformat()
            expected_end = tp_datetime(*expected_end).isoformat()

            dates = period.get(TIMES)
            assertTrue(isinstance(dates, tuple))

            start, end = dates

            assertEqual(start, expected_start,
                        msg="Period %s start should be %s, but is %s" %
                        (i, expected_start, start))
            assertEqual(end, expected_end,
                        msg="Period %s end should be %s, but is %s" %
                        (i, expected_end, end))

            value = period.get(VALUE)
            assertEqual(value, expected_value,
                        msg="Period %s cumulative sum should be %s, but is %s" %
                        (i, expected_value, value))

    # -------------------------------------------------------------------------
Configure icon of the item
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3timeplot.py/TimeSeriesTests.testEventDataCumulativeAggregation--crossover with--dataset/ETHPy150Open tuturto/pyherc/src/pyherc/test/builders/item.py/ItemBuilder.with_icon