def test_identity(self):
     ctx = {
         'startTime': parseATTime('-1d'),
         'endTime': parseATTime('now'),
     }
     identity = functions.identity(ctx, 'foo')[0]
     self.assertEqual(identity.end - identity.start, 3600 * 24)
    def test_smart_summarize(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
            'tzinfo': pytz.timezone('UTC'),
        }
        series = self._generate_series_list(config=[range(100)])
        for s in series:
            self.write_series(s)
        summ = functions.smartSummarize(ctx, series, '5s')[0]
        self.assertEqual(summ[:3], [220, 245, 270])

        summ = functions.smartSummarize(ctx, series, '5s', 'avg')[0]
        self.assertEqual(summ[:3], [44, 49, 54])

        summ = functions.smartSummarize(ctx, series, '5s', 'last')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'max')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'min')[0]
        self.assertEqual(summ[:3], [42, 47, 52])

        # Higher time interval should not trigger timezone errors
        functions.smartSummarize(ctx, series, '100s', 'min')[0]
 def test_random_walk(self):
     ctx = {
         'startTime': parseATTime('-12h'),
         'endTime': parseATTime('now'),
     }
     walk = functions.randomWalkFunction(ctx, 'foo')[0]
     self.assertEqual(len(walk), 721)
    def test_smart_summarize(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
            'tzinfo': pytz.timezone('UTC'),
        }
        series = self._generate_series_list(config=[range(100)])
        for s in series:
            self.write_series(s)
        summ = functions.smartSummarize(ctx, series, '5s')[0]
        self.assertEqual(summ[:3], [220, 245, 270])

        summ = functions.smartSummarize(ctx, series, '5s', 'avg')[0]
        self.assertEqual(summ[:3], [44, 49, 54])

        summ = functions.smartSummarize(ctx, series, '5s', 'last')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'max')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'min')[0]
        self.assertEqual(summ[:3], [42, 47, 52])

        # Higher time interval should not trigger timezone errors
        functions.smartSummarize(ctx, series, '100s', 'min')[0]
 def test_random_walk(self):
     ctx = {
         'startTime': parseATTime('-12h'),
         'endTime': parseATTime('now'),
     }
     walk = functions.randomWalkFunction(ctx, 'foo')[0]
     self.assertEqual(len(walk), 721)
 def test_identity(self):
     ctx = {
         'startTime': parseATTime('-1d'),
         'endTime': parseATTime('now'),
     }
     identity = functions.identity(ctx, 'foo')[0]
     self.assertEqual(identity.end - identity.start, 3600 * 24)
 def test_constant_line(self):
     ctx = {
         'startTime': parseATTime('-1d'),
         'endTime': parseATTime('now'),
     }
     line = functions.constantLine(ctx, 12)[0]
     self.assertEqual(list(line), [12, 12])
     self.assertEqual(line.step, 3600 * 24)
    def test_agg_line(self):
        ctx = {"startTime": parseATTime("-1d"), "endTime": parseATTime("now")}
        series = self._generate_series_list(config=[range(100)])
        line = functions.aggregateLine(ctx, series)[0]
        self.assertEqual(list(line), [49.5, 49.5])

        with self.assertRaises(ValueError):
            functions.aggregateLine(ctx, series, "foo")
 def test_constant_line(self):
     ctx = {
         'startTime': parseATTime('-1d'),
         'endTime': parseATTime('now'),
     }
     line = functions.constantLine(ctx, 12)[0]
     self.assertEqual(list(line), [12, 12])
     self.assertEqual(line.step, 3600 * 24)
    def test_absolute_time(self):
        time_string = "12:0020150308"
        expected_time = self.default_tz.localize(datetime.datetime.strptime(time_string, "%H:%M%Y%m%d"))
        actual_time = parseATTime(time_string)
        self.assertEqual(actual_time, expected_time)

        expected_time = self.specified_tz.localize(datetime.datetime.strptime(time_string, "%H:%M%Y%m%d"))
        actual_time = parseATTime(time_string, self.specified_tz)
        self.assertEqual(actual_time, expected_time)
    def test_agg_line(self):
        ctx = {
            'startTime': parseATTime('-1d'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[range(100)])
        line = functions.aggregateLine(ctx, series)[0]
        self.assertEqual(list(line), [49.5, 49.5])

        with self.assertRaises(ValueError):
            functions.aggregateLine(ctx, series, 'foo')
    def test_threshold(self):
        ctx = {"startTime": parseATTime("-1d"), "endTime": parseATTime("now")}
        threshold = functions.threshold(ctx, 123, "foobar")[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123)[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123, "foo", "red")[0]
        self.assertEqual(list(threshold), [123, 123])
        self.assertEqual(threshold.color, "red")
    def test_hitcount(self):
        ctx = {"startTime": parseATTime("-1min"), "endTime": parseATTime("now")}
        series = self._generate_series_list(config=[list(range(99)) + [None]])
        for s in series:
            self.write_series(s)

        hit = functions.hitcount(ctx, series, "5s")[0]
        self.assertEqual(hit[:3], [0, 15, 40])

        hit = functions.hitcount(ctx, series, "5s", True)[0]
        self.assertEqual(hit[:3], [220, 245, 270])
Exemple #14
0
    def test_absolute_time(self):
        time_string = '12:0020150308'
        expected_time = self.default_tz.localize(
            datetime.datetime.strptime(time_string, '%H:%M%Y%m%d'))
        actual_time = parseATTime(time_string)
        self.assertEqual(actual_time, expected_time)

        expected_time = self.specified_tz.localize(
            datetime.datetime.strptime(time_string, '%H:%M%Y%m%d'))
        actual_time = parseATTime(time_string, self.specified_tz)
        self.assertEqual(actual_time, expected_time)
    def test_agg_line(self):
        ctx = {
            'startTime': parseATTime('-1d'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[range(100)])
        line = functions.aggregateLine(ctx, series)[0]
        self.assertEqual(list(line), [49.5, 49.5])

        with self.assertRaises(ValueError):
            functions.aggregateLine(ctx, series, 'foo')
    def test_threshold(self):
        ctx = {
            'startTime': parseATTime('-1d'),
            'endTime': parseATTime('now'),
        }
        threshold = functions.threshold(ctx, 123, 'foobar')[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123)[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123, 'foo', 'red')[0]
        self.assertEqual(list(threshold), [123, 123])
        self.assertEqual(threshold.color, 'red')
    def test_hitcount(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[list(range(99)) + [None]])
        for s in series:
            self.write_series(s)

        hit = functions.hitcount(ctx, series, '5s')[0]
        self.assertEqual(hit[:3], [0, 15, 40])

        hit = functions.hitcount(ctx, series, '5s', True)[0]
        self.assertEqual(hit[:3], [220, 245, 270])
    def test_moving_median(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        tzinfo = pytz.timezone(app.config['TIME_ZONE'])
        median = functions.movingMedian({
            'startTime': parseATTime('-100s', tzinfo=tzinfo)
        }, series, '5s')[0]
        self.assertEqual(median[:4], [1, 0, 1, 1])

        median = functions.movingMedian({
            'startTime': parseATTime('-100s', tzinfo=tzinfo)
        }, series, 5)[0]
        self.assertEqual(median[:4], [1, 0, 1, 1])
    def test_hitcount(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[list(range(99)) + [None]])
        for s in series:
            self.write_series(s)

        hit = functions.hitcount(ctx, series, '5s')[0]
        self.assertEqual(hit[:3], [0, 15, 40])

        hit = functions.hitcount(ctx, series, '5s', True)[0]
        self.assertEqual(hit[:3], [220, 245, 270])
    def test_threshold(self):
        ctx = {
            'startTime': parseATTime('-1d'),
            'endTime': parseATTime('now'),
        }
        threshold = functions.threshold(ctx, 123, 'foobar')[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123)[0]
        self.assertEqual(list(threshold), [123, 123])

        threshold = functions.threshold(ctx, 123, 'foo', 'red')[0]
        self.assertEqual(list(threshold), [123, 123])
        self.assertEqual(threshold.color, 'red')
    def test_moving_average(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        tzinfo = pytz.timezone(app.config['TIME_ZONE'])
        average = functions.movingAverage({
            'startTime': parseATTime('-100s', tzinfo=tzinfo)
        }, series, '5s')[0]
        self.assertEqual(list(average)[:4], [0.5, 1/3., 0.5, 0.8])

        average = functions.movingAverage({
            'startTime': parseATTime('-100s', tzinfo=tzinfo)
        }, series, 5)[0]
        self.assertEqual(average[:4], [0.5, 1/3., 0.5, 0.8])
    def test_time_stack(self):
        timespan = 3600 * 24 * 8  # 8 days
        stop = int(time.time())
        step = 100
        series = TimeSeries("foo.bar", stop - timespan, stop, step, [x ** 1.5 for x in range(0, timespan, step)])
        series[10] = None
        series.pathExpression = "foo.bar"
        self.write_series(series, [(100, timespan)])

        ctx = {"startTime": parseATTime("-1d"), "endTime": parseATTime("now")}
        stack = functions.timeStack(ctx, [series], "1d", 0, 7)
        self.assertEqual(len(stack), 7)

        stack = functions.timeStack(ctx, [series], "-1d", 0, 7)
        self.assertEqual(len(stack), 7)
    def test_moving_average(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        average = functions.movingAverage({"startTime": parseATTime("-100s")}, series, "5s")[0]
        try:
            self.assertEqual(list(average)[:4], [0.5, 1 / 3.0, 0.5, 0.8])
        except AssertionError:  # time race condition
            self.assertEqual(list(average)[:4], [1, 3 / 4.0, 0.8, 1.2])

        average = functions.movingAverage({"startTime": parseATTime("-100s")}, series, 5)[0]
        try:
            self.assertEqual(average[:4], [0.5, 1 / 3.0, 0.5, 0.8])
        except AssertionError:
            self.assertEqual(list(average)[:4], [1, 3 / 4.0, 0.8, 1.2])
    def test_moving_median(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        median = functions.movingMedian({"startTime": parseATTime("-100s")}, series, "5s")[0]
        try:
            self.assertEqual(median[:4], [1, 0, 1, 1])
        except AssertionError:  # time race condition
            self.assertEqual(median[:4], [1, 1, 1, 1])

        median = functions.movingMedian({"startTime": parseATTime("-100s")}, series, 5)[0]
        try:
            self.assertEqual(median[:4], [1, 0, 1, 1])
        except AssertionError:
            self.assertEqual(median[:4], [1, 1, 1, 1])
    def test_holt_winters(self):
        timespan = 3600 * 24 * 8  # 8 days
        stop = int(time.time())
        step = 100
        series = TimeSeries('foo.bar',
                            stop - timespan,
                            stop,
                            step,
                            [x**1.5 for x in range(0, timespan, step)])
        series[10] = None
        series.pathExpression = 'foo.bar'
        self.write_series(series, [(100, timespan)])

        ctx = {
            'startTime': parseATTime('-1d'),
        }
        analysis = functions.holtWintersForecast(ctx, [series])
        self.assertEqual(len(analysis), 1)

        analysis = functions.holtWintersConfidenceBands(ctx, [series])
        self.assertEqual(len(analysis), 2)

        analysis = functions.holtWintersConfidenceArea(ctx, [series])
        self.assertEqual(len(analysis), 2)

        analysis = functions.holtWintersAberration(ctx, [series])
        self.assertEqual(len(analysis), 1)
    def test_time_stack(self):
        timespan = 3600 * 24 * 8  # 8 days
        stop = int(time.time())
        step = 100
        series = TimeSeries('foo.bar', stop - timespan, stop, step,
                            [x**1.5 for x in range(0, timespan, step)])
        series[10] = None
        series.pathExpression = 'foo.bar'
        self.write_series(series, [(100, timespan)])

        ctx = {'startTime': parseATTime('-1d'), 'endTime': parseATTime('now')}
        stack = functions.timeStack(ctx, [series], '1d', 0, 7)
        self.assertEqual(len(stack), 7)

        stack = functions.timeStack(ctx, [series], '-1d', 0, 7)
        self.assertEqual(len(stack), 7)
    def test_moving_median(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        median = functions.movingMedian({'startTime': parseATTime('-100s')},
                                        series, '5s')[0]
        try:
            self.assertEqual(median[:4], [1, 0, 1, 1])
        except AssertionError:  # time race condition
            self.assertEqual(median[:4], [1, 1, 1, 1])

        median = functions.movingMedian({'startTime': parseATTime('-100s')},
                                        series, 5)[0]
        try:
            self.assertEqual(median[:4], [1, 0, 1, 1])
        except AssertionError:
            self.assertEqual(median[:4], [1, 1, 1, 1])
    def test_moving_average(self):
        series = self._generate_series_list()
        for s in series:
            self.write_series(s)
        average = functions.movingAverage({'startTime': parseATTime('-100s')},
                                          series, '5s')[0]
        try:
            self.assertEqual(list(average)[:4], [0.5, 1 / 3., 0.5, 0.8])
        except AssertionError:  # time race condition
            self.assertEqual(list(average)[:4], [1, 3 / 4., 0.8, 1.2])

        average = functions.movingAverage({'startTime': parseATTime('-100s')},
                                          series, 5)[0]
        try:
            self.assertEqual(average[:4], [0.5, 1 / 3., 0.5, 0.8])
        except AssertionError:
            self.assertEqual(list(average)[:4], [1, 3 / 4., 0.8, 1.2])
    def test_use_series_above(self):
        series = self._generate_series_list(config=[list(range(90)) + [None] * 10])
        series[0].pathExpression = "bar"

        for s in series:
            self.write_series(s)

        series[0].name = "foo"

        ctx = {"startTime": parseATTime("-100s"), "endTime": parseATTime("now")}
        above = functions.useSeriesAbove(ctx, series, 10, "foo", "bar")[0]
        self.assertEqual(above[0], 2)

        above = functions.useSeriesAbove(ctx, series, 100, "foo", "bar")
        self.assertEqual(len(above), 0)

        above = functions.useSeriesAbove(ctx, series, 10, "foo", "baz")
        self.assertEqual(len(above), 0)
Exemple #30
0
    def test_parse(self):
        for value in [
                str(int(time.time())),
                '20140319',
                '20130319+1y',
                '20130319+1mon',
                '20130319+1w',
                '12:12_20130319',
                '3:05am_20130319',
                '3:05pm_20130319',
                'noon20130319',
                'midnight20130319',
                'teatime20130319',
                'yesterday',
                'tomorrow',
                '03/19/2014',
                '03/19/1800',
                '03/19/1950',
                'feb 27',
                'mar 5',
                'mon',
                'tue',
                'wed',
                'thu',
                'fri',
                'sat',
                'sun',
                '10:00',
                '20160229-1year',
                '20160229-4years',
                '20160229-1month',
                '20130228-1year',
                '20130228-4years',
                '20130228-1month',
        ]:
            self.assertIsInstance(parseATTime(value), datetime.datetime)

        for value in [
                '20130319+1foo',
                'mar',
                'wat',
        ]:
            with self.assertRaises(Exception):
                parseATTime(value)
    def test_smart_summarize(self):
        ctx = {"startTime": parseATTime("-1min"), "endTime": parseATTime("now")}
        series = self._generate_series_list(config=[range(100)])
        for s in series:
            self.write_series(s)
        summ = functions.smartSummarize(ctx, series, "5s")[0]
        self.assertEqual(summ[:3], [220, 245, 270])

        summ = functions.smartSummarize(ctx, series, "5s", "avg")[0]
        self.assertEqual(summ[:3], [44, 49, 54])

        summ = functions.smartSummarize(ctx, series, "5s", "last")[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, "5s", "max")[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, "5s", "min")[0]
        self.assertEqual(summ[:3], [42, 47, 52])
    def test_time_stack(self):
        timespan = 3600 * 24 * 8  # 8 days
        stop = int(time.time())
        step = 100
        series = TimeSeries('foo.bar',
                            stop - timespan,
                            stop,
                            step,
                            [x**1.5 for x in range(0, timespan, step)])
        series[10] = None
        series.pathExpression = 'foo.bar'
        self.write_series(series, [(100, timespan)])

        ctx = {'startTime': parseATTime('-1d'),
               'endTime': parseATTime('now')}
        stack = functions.timeStack(ctx, [series], '1d', 0, 7)
        self.assertEqual(len(stack), 7)

        stack = functions.timeStack(ctx, [series], '-1d', 0, 7)
        self.assertEqual(len(stack), 7)
    def test_parse(self):
        for value in [
            str(int(time.time())),
            "20140319",
            "20130319+1y",
            "20130319+1mon",
            "20130319+1w",
            "12:12_20130319",
            "3:05am_20130319",
            "3:05pm_20130319",
            "noon20130319",
            "midnight20130319",
            "teatime20130319",
            "yesterday",
            "tomorrow",
            "03/19/2014",
            "03/19/1800",
            "03/19/1950",
            "feb 27",
            "mar 5",
            "mon",
            "tue",
            "wed",
            "thu",
            "fri",
            "sat",
            "sun",
            "10:00",
            "20160229-1year",
            "20160229-4years",
            "20160229-1month",
            "20130228-1year",
            "20130228-4years",
            "20130228-1month",
        ]:
            self.assertIsInstance(parseATTime(value), datetime.datetime)

        for value in ["20130319+1foo", "mar", "wat"]:
            with self.assertRaises(Exception):
                parseATTime(value)
    def test_smart_summarize(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[range(100)])
        for s in series:
            self.write_series(s)
        summ = functions.smartSummarize(ctx, series, '5s')[0]
        self.assertEqual(summ[:3], [220, 245, 270])

        summ = functions.smartSummarize(ctx, series, '5s', 'avg')[0]
        self.assertEqual(summ[:3], [44, 49, 54])

        summ = functions.smartSummarize(ctx, series, '5s', 'last')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'max')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'min')[0]
        self.assertEqual(summ[:3], [42, 47, 52])
Exemple #35
0
    def test_smart_summarize(self):
        ctx = {
            'startTime': parseATTime('-1min'),
            'endTime': parseATTime('now'),
        }
        series = self._generate_series_list(config=[range(100)])
        for s in series:
            self.write_series(s)
        summ = functions.smartSummarize(ctx, series, '5s')[0]
        self.assertEqual(summ[:3], [220, 245, 270])

        summ = functions.smartSummarize(ctx, series, '5s', 'avg')[0]
        self.assertEqual(summ[:3], [44, 49, 54])

        summ = functions.smartSummarize(ctx, series, '5s', 'last')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'max')[0]
        self.assertEqual(summ[:3], [46, 51, 56])

        summ = functions.smartSummarize(ctx, series, '5s', 'min')[0]
        self.assertEqual(summ[:3], [42, 47, 52])
    def test_use_series_above(self):
        series = self._generate_series_list(
            config=[list(range(90)) + [None] * 10])
        series[0].pathExpression = 'bar'

        for s in series:
            self.write_series(s)

        series[0].name = 'foo'

        ctx = {
            'startTime': parseATTime('-100s'),
            'endTime': parseATTime('now'),
        }
        above = functions.useSeriesAbove(ctx, series, 10, 'foo', 'bar')[0]
        self.assertEqual(above[0], 2)

        above = functions.useSeriesAbove(ctx, series, 100, 'foo', 'bar')
        self.assertEqual(len(above), 0)

        above = functions.useSeriesAbove(ctx, series, 10, 'foo', 'baz')
        self.assertEqual(len(above), 0)
    def test_use_series_above(self):
        series = self._generate_series_list(
            config=[list(range(90)) + [None] * 10])
        series[0].pathExpression = 'bar'

        for s in series:
            self.write_series(s)

        series[0].name = 'foo'

        ctx = {
            'startTime': parseATTime('-100s'),
            'endTime': parseATTime('now'),
        }
        above = functions.useSeriesAbove(ctx, series, 10, 'foo', 'bar')[0]
        self.assertEqual(above[0], 2)

        above = functions.useSeriesAbove(ctx, series, 100, 'foo', 'bar')
        self.assertEqual(len(above), 0)

        above = functions.useSeriesAbove(ctx, series, 10, 'foo', 'baz')
        self.assertEqual(len(above), 0)
    def test_parse(self):
        for value in [
            str(int(time.time())),
            '20140319',
            '20130319+1y',
            '20130319+1mon',
            '20130319+1w',
            '12:12_20130319',
            '3:05am_20130319',
            '3:05pm_20130319',
            'noon20130319',
            'midnight20130319',
            'teatime20130319',
            'yesterday',
            'tomorrow',
            '03/19/2014',
            '03/19/1800',
            '03/19/1950',
            'feb 27',
            'mar 5',
            'mon',
            'tue',
            'wed',
            'thu',
            'fri',
            'sat',
            'sun',
            '10:00',
        ]:
            self.assertIsInstance(parseATTime(value), datetime.datetime)

        for value in [
            '20130319+1foo',
            'mar',
            'wat',
        ]:
            with self.assertRaises(Exception):
                parseATTime(value)
    def test_holt_winters(self):
        timespan = 3600 * 24 * 8  # 8 days
        stop = int(time.time())
        step = 100
        series = TimeSeries('foo.bar', stop - timespan, stop, step,
                            [x**1.5 for x in range(0, timespan, step)])
        series[10] = None
        series.pathExpression = 'foo.bar'
        self.write_series(series, [(100, timespan)])

        ctx = {
            'startTime': parseATTime('-1d'),
        }
        analysis = functions.holtWintersForecast(ctx, [series])
        self.assertEqual(len(analysis), 1)

        analysis = functions.holtWintersConfidenceBands(ctx, [series])
        self.assertEqual(len(analysis), 2)

        analysis = functions.holtWintersConfidenceArea(ctx, [series])
        self.assertEqual(len(analysis), 2)

        analysis = functions.holtWintersAberration(ctx, [series])
        self.assertEqual(len(analysis), 1)
 def test_constant_line(self):
     ctx = {"startTime": parseATTime("-1d"), "endTime": parseATTime("now")}
     line = functions.constantLine(ctx, 12)[0]
     self.assertEqual(list(line), [12, 12])
     self.assertEqual(line.step, 3600 * 24)
 def test_identity(self):
     ctx = {"startTime": parseATTime("-1d"), "endTime": parseATTime("now")}
     identity = functions.identity(ctx, "foo")[0]
     self.assertEqual(identity.end - identity.start, 3600 * 24)
 def test_random_walk(self):
     ctx = {"startTime": parseATTime("-12h"), "endTime": parseATTime("now")}
     walk = functions.randomWalkFunction(ctx, "foo")[0]
     self.assertEqual(len(walk), 721)