示例#1
0
 def test_functionality(self):
     ''' Make sure it produces a reasonable result for typical input '''
     result = list(
         raw_analyze._preprocess_results([
             (1234567890, 1440),
             (1234567891, 1440),
             (1234567894, 1440),
             (1234567894, 1440),
             (1234567899, 1440),
         ], True))
     self.assertEqual(result, [(1234567890, 0, 1440), (1234567891, 1, 1440),
                               (1234567894, 3, 2880),
                               (1234567899, 5, 1440)])
     # Same as above, but without merging points with equal ticks
     result = list(
         raw_analyze._preprocess_results([
             (1234567890, 1440),
             (1234567891, 1440),
             (1234567894, 1440),
             (1234567894, 1440),
             (1234567899, 1440),
         ], False))
     self.assertEqual(result, [(1234567890, 0, 1440), (1234567891, 1, 1440),
                               (1234567894, 3, 1440), (1234567894, 0, 1440),
                               (1234567899, 5, 1440)])
示例#2
0
 def test_functionality(self):
     ''' Make sure it produces a reasonable result for typical input '''
     result = list(raw_analyze._preprocess_results([
                                                    (1234567890, 1440),
                                                    (1234567891, 1440),
                                                    (1234567894, 1440),
                                                    (1234567894, 1440),
                                                    (1234567899, 1440),
                                                   ],
                                                   True))
     self.assertEqual(result, [
                               (1234567890, 0, 1440),
                               (1234567891, 1, 1440),
                               (1234567894, 3, 2880),
                               (1234567899, 5, 1440)
                              ])
     # Same as above, but without merging points with equal ticks
     result = list(raw_analyze._preprocess_results([
                                                    (1234567890, 1440),
                                                    (1234567891, 1440),
                                                    (1234567894, 1440),
                                                    (1234567894, 1440),
                                                    (1234567899, 1440),
                                                   ],
                                                   False))
     self.assertEqual(result, [
                               (1234567890, 0, 1440),
                               (1234567891, 1, 1440),
                               (1234567894, 3, 1440),
                               (1234567894, 0, 1440),
                               (1234567899, 5, 1440)
                              ])
示例#3
0
 def test_negative_interval(self):
     ''' Make sure we raise RuntimeError on negative interval '''
     generator = raw_analyze._preprocess_results([
                                                  (1234567890, 1440),
                                                  (1234567889, 1440)
                                                 ],
                                                 False)
     self.assertRaises(RuntimeError, list, generator)
示例#4
0
 def test_first_point(self):
     ''' Make sure that the first point interval is computed properly '''
     result = list(
         raw_analyze._preprocess_results([
             (1234567890, 1440),
             (1234567891, 1440),
             (1234567892, 1440),
         ], False))
     self.assertEqual(result[0][1], 0)
示例#5
0
 def test_first_point(self):
     ''' Make sure that the first point interval is computed properly '''
     result = list(raw_analyze._preprocess_results([
                                                    (1234567890, 1440),
                                                    (1234567891, 1440),
                                                    (1234567892, 1440),
                                                   ],
                                                   False))
     self.assertEqual(result[0][1], 0)
示例#6
0
 def test_merge_points(self):
     ''' Make sure that the points are correctly merged '''
     result = list(
         raw_analyze._preprocess_results([
             (1234567890, 1440),
             (1234567890, 1440),
             (1234567892, 1440),
             (1234567892, 1440),
         ], True))
     self.assertEqual(len(result), 2)
     self.assertEqual(result[0][2], 2880)
     self.assertEqual(result[1][2], 2880)
示例#7
0
 def test_merge_points(self):
     ''' Make sure that the points are correctly merged '''
     result = list(raw_analyze._preprocess_results([
                                                    (1234567890, 1440),
                                                    (1234567890, 1440),
                                                    (1234567892, 1440),
                                                    (1234567892, 1440),
                                                   ],
                                                   True))
     self.assertEqual(len(result), 2)
     self.assertEqual(result[0][2], 2880)
     self.assertEqual(result[1][2], 2880)
示例#8
0
 def test_nonmerge_points(self):
     ''' Make sure interval is zero when we don't merge points '''
     result = list(
         raw_analyze._preprocess_results([
             (1234567890, 1440),
             (1234567890, 1440),
             (1234567892, 1440),
             (1234567892, 1440),
         ], False))
     self.assertEqual(len(result), 4)
     self.assertEqual(result[1][1], 0.0)
     self.assertEqual(result[1][2], 1440)
     self.assertEqual(result[3][1], 0.0)
     self.assertEqual(result[3][2], 1440)
示例#9
0
 def test_nonmerge_points(self):
     ''' Make sure interval is zero when we don't merge points '''
     result = list(raw_analyze._preprocess_results([
                                                    (1234567890, 1440),
                                                    (1234567890, 1440),
                                                    (1234567892, 1440),
                                                    (1234567892, 1440),
                                                   ],
                                                   False))
     self.assertEqual(len(result), 4)
     self.assertEqual(result[1][1], 0.0)
     self.assertEqual(result[1][2], 1440)
     self.assertEqual(result[3][1], 0.0)
     self.assertEqual(result[3][2], 1440)
示例#10
0
 def test_negative_interval(self):
     ''' Make sure we raise RuntimeError on negative interval '''
     generator = raw_analyze._preprocess_results([(1234567890, 1440),
                                                  (1234567889, 1440)],
                                                 False)
     self.assertRaises(RuntimeError, list, generator)
示例#11
0
 def test_empty(self):
     ''' Make sure it works for empty input '''
     self.assertEqual(list(raw_analyze._preprocess_results([], False)), [])
示例#12
0
 def test_empty(self):
     ''' Make sure it works for empty input '''
     self.assertEqual(list(raw_analyze._preprocess_results([], False)), [])