def testEventDataAggregation(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",
                          end = "2013-01-01",
                          slots = "months",
                          facts = [S3TimeSeriesFact("sum", "parameter1")],
                          )

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

        expected = [
            ((2011,1,3), (2011,2,3), [15]),        # 00 P NS1 NS2 NS3 SE1
            ((2011,2,3), (2011,3,3), [15]),        # 01 P NS1 NS2 NS3 SE1
            ((2011,3,3), (2011,4,3), [15]),        # 02 P NS1 NS2 NS3 SE1
            ((2011,4,3), (2011,5,3), [18]),        # 03 P NS1 NS2 NS3 SE1 SE2
            ((2011,5,3), (2011,6,3), [18]),        # 04 P NS1 NS2 NS3 SE1 SE2
            ((2011,6,3), (2011,7,3), [15]),        # 05 P NS1 NS2 NS3 SE2
            ((2011,7,3), (2011,8,3), [18]),        # 06 P NS1 NS2 NS3 SE2 SE3
            ((2011,8,3), (2011,9,3), [18]),        # 07 P NS1 NS2 NS3 SE2 SE3
            ((2011,9,3), (2011,10,3), [15]),       # 08 P NS1 NS2 NS3 SE3
            ((2011,10,3), (2011,11,3), [15]),      # 09 P NS1 NS2 NS3 SE3
            ((2011,11,3), (2011,12,3), [15]),      # 10 P NS1 NS2 NS3 SE3
            ((2011,12,3), (2012,1,3), [12]),       # 11 P NS1 NS2 NS3
            ((2012,1,3), (2012,2,3), [12]),        # 12 P NS1 NS2 NS3
            ((2012,2,3), (2012,3,3), [12]),        # 13 P NS1 NS2 NS3
            ((2012,3,3), (2012,4,3), [9]),         # 14 P NS2 NS3
            ((2012,4,3), (2012,5,3), [9]),         # 15 P NS2 NS3
            ((2012,5,3), (2012,6,3), [9]),         # 16 P NS2 NS3
            ((2012,6,3), (2012,7,3), [6]),         # 17 P NS3
            ((2012,7,3), (2012,8,3), [9]),         # 18 P NS3 NE1
            ((2012,8,3), (2012,9,3), [9]),         # 19 P NS3 NE1
            ((2012,9,3), (2012,10,3), [6]),        # 20 P NE1
            ((2012,10,3), (2012,11,3), [9]),       # 21 P NE1 NE2
            ((2012,11,3), (2012,12,3), [9]),       # 22 P NE1 NE2
            ((2012,12,3), (2013,1,1), [9]),        # 23 P 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 sum should be %s, but is %s" %
                        (i, expected_value, value))

    # -------------------------------------------------------------------------
Starts a server.
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3timeplot.py/TimeSeriesTests.testEventDataAggregation--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/request_info.py/_LocalFakeDispatcher.start_server