Commits

Chris Perl  committed 3d75cf7

Updating unittests to use new interface

  • Participants
  • Parent commits 86d97b9

Comments (0)

Files changed (1)

File test/tests.py

 
 # TODO: Figure out a good way to vary time periods
 
+def dt(datetime_str):
+    """
+    Takes a string like '2011-10-24 00:00:00' and convert it into a datetime object
+    """
+    return datetime(*[int(x) for x in re.split('[-: ]', datetime_str)])
+
 class LogFileTester(unittest.TestCase):
     def setUp(self):
         self._devnull = open(os.devnull, 'w')
     def tearDown(self):
         self._devnull.close()
 
-    def _test_HitsPerXPerUnitTime(self, class_name, expected_data, step, re_filter, expected_keys):
-        instance = getattr(self, class_name)
-        instance(start=self.log_analyzer.start, end=self.log_analyzer.end,
-                 step=step, re_filter=re_filter)
-        self.assertEqual(len(instance.aggr_data.keys()), expected_keys)
-        for key, time_tuple, count in expected_data:
-            bottom = datetime(*[int(x) for x in re.split('[-:]', time_tuple[0])])
-            top    = datetime(*[int(x) for x in re.split('[-:]', time_tuple[1])])
-            self.assertEqual(instance.aggr_data[key][(bottom, top)], count)
-
-    def _test_HitsPerXByTimeToRenderLinear(self, class_name, expected_data, 
-                                           ms_step, re_filter, expected_keys):
-        instance = getattr(self, class_name)
-        instance(start=self.log_analyzer.start, end=self.log_analyzer.end,
-                 ms_step=ms_step, re_filter=re_filter)
-        self.assertEqual(len(instance.aggr_data.keys()), expected_keys)
-        for key, speed_tuple, count in expected_data:
-            bottom = speed_tuple[0]
-            top    = speed_tuple[1]
-            self.assertEqual(instance.aggr_data[key][(bottom, top)], count)
-
 class October24th2011_AppServer06_Port8131(LogFileTester):
     def _setup_log_paths(self):
         self.logs = glob.glob(
         self.log_analyzer.do_cmd("toptalkers --filter '^208\.92\.'")
         self.assertEqual(self.log_analyzer._hpi.aggr_data, expected_data)
 
-    def _test_HitsPerUrlPerUnitTime(self):
+    def test_HitsPerUrlPerUnitTime3600(self):
         expected_data = { 
-            'www.nhl.com/ice/m_home.htm': 20645
-            ('2011-10-24 00:00:00', '2011-10-24 00:59:59'):                 1775,
-            ('2011-10-24 01:00:00', '2011-10-24 01:59:59'):                 1236,
-            ('2011-10-24 02:00:00', '2011-10-24 02:59:59'):                  355,
-            ('2011-10-24 03:00:00', '2011-10-24 03:59:59'):                  212,
-            ('2011-10-24 04:00:00', '2011-10-24 04:59:59'):                  239,
-            ('2011-10-24 05:00:00', '2011-10-24 05:59:59'):                  254,
-            ('2011-10-24 06:00:00', '2011-10-24 06:59:59'):                  297,
-            ('2011-10-24 07:00:00', '2011-10-24 07:59:59'):                  327,
-            ('2011-10-24 08:00:00', '2011-10-24 08:59:59'):                  383,
-            ('2011-10-24 09:00:00', '2011-10-24 09:59:59'):                  463,
-            ('2011-10-24 10:00:00', '2011-10-24 10:59:59'):                  484,
-            ('2011-10-24 11:00:00', '2011-10-24 11:59:59'):                  514,
-            ('2011-10-24 12:00:00', '2011-10-24 12:59:59'):                  585,
-            ('2011-10-24 13:00:00', '2011-10-24 13:59:59'):                  494,
-            ('2011-10-24 14:00:00', '2011-10-24 14:59:59'):                  582,
-            ('2011-10-24 15:00:00', '2011-10-24 15:59:59'):                  559,
-            ('2011-10-24 16:00:00', '2011-10-24 16:59:59'):                  585,
-            ('2011-10-24 17:00:00', '2011-10-24 17:59:59'):                  709,
-            ('2011-10-24 18:00:00', '2011-10-24 18:59:59'):                  815,
-            ('2011-10-24 19:00:00', '2011-10-24 19:59:59'):                 1882,
-            ('2011-10-24 20:00:00', '2011-10-24 20:59:59'):                 2292,
-            ('2011-10-24 21:00:00', '2011-10-24 21:59:59'):                 2695,
-            ('2011-10-24 22:00:00', '2011-10-24 22:59:59'):                 1858,
-            ('2011-10-24 23:00:00', '2011-10-24 23:59:59'):                 1050,
+            'www.nhl.com/ice/m_home.htm': { 'hits':             20645,
+                (dt('2011-10-24 00:00:00'), dt('2011-10-24 00:59:59')): 1775,
+                (dt('2011-10-24 01:00:00'), dt('2011-10-24 01:59:59')): 1236,
+                (dt('2011-10-24 02:00:00'), dt('2011-10-24 02:59:59')): 355,
+                (dt('2011-10-24 03:00:00'), dt('2011-10-24 03:59:59')): 212,
+                (dt('2011-10-24 04:00:00'), dt('2011-10-24 04:59:59')): 239,
+                (dt('2011-10-24 05:00:00'), dt('2011-10-24 05:59:59')): 254,
+                (dt('2011-10-24 06:00:00'), dt('2011-10-24 06:59:59')): 297,
+                (dt('2011-10-24 07:00:00'), dt('2011-10-24 07:59:59')): 327,
+                (dt('2011-10-24 08:00:00'), dt('2011-10-24 08:59:59')): 383,
+                (dt('2011-10-24 09:00:00'), dt('2011-10-24 09:59:59')): 463,
+                (dt('2011-10-24 10:00:00'), dt('2011-10-24 10:59:59')): 484,
+                (dt('2011-10-24 11:00:00'), dt('2011-10-24 11:59:59')): 514,
+                (dt('2011-10-24 12:00:00'), dt('2011-10-24 12:59:59')): 585,
+                (dt('2011-10-24 13:00:00'), dt('2011-10-24 13:59:59')): 494,
+                (dt('2011-10-24 14:00:00'), dt('2011-10-24 14:59:59')): 582,
+                (dt('2011-10-24 15:00:00'), dt('2011-10-24 15:59:59')): 559,
+                (dt('2011-10-24 16:00:00'), dt('2011-10-24 16:59:59')): 585,
+                (dt('2011-10-24 17:00:00'), dt('2011-10-24 17:59:59')): 709,
+                (dt('2011-10-24 18:00:00'), dt('2011-10-24 18:59:59')): 815,
+                (dt('2011-10-24 19:00:00'), dt('2011-10-24 19:59:59')): 1882,
+                (dt('2011-10-24 20:00:00'), dt('2011-10-24 20:59:59')): 2292,
+                (dt('2011-10-24 21:00:00'), dt('2011-10-24 21:59:59')): 2695,
+                (dt('2011-10-24 22:00:00'), dt('2011-10-24 22:59:59')): 1858,
+                (dt('2011-10-24 23:00:00'), dt('2011-10-24 23:59:59')): 1050,
+            }
         }
+        self.log_analyzer.do_cmd("url-hits-per-time --filter '/ice/m_home\.htm$'")
+        self.assertEqual(self.log_analyzer._hpuput.aggr_data, expected_data)
 
+    def test_HitsPerUrlPerUnitTime8500(self):
+        expected_data = {
+            'www.nhl.com/ice/m_menu.htm': { 'hits': 3792,
+                (dt('2011-10-24 00:00:00'), dt('2011-10-24 02:21:39')): 220,
+                (dt('2011-10-24 02:21:40'), dt('2011-10-24 04:43:19')): 126,
+                (dt('2011-10-24 04:43:20'), dt('2011-10-24 07:04:59')): 114,
+                (dt('2011-10-24 07:05:00'), dt('2011-10-24 09:26:39')): 152,
+                (dt('2011-10-24 09:26:40'), dt('2011-10-24 11:48:19')): 208,
+                (dt('2011-10-24 11:48:20'), dt('2011-10-24 14:09:59')): 222,
+                (dt('2011-10-24 14:10:00'), dt('2011-10-24 16:31:39')): 232,
+                (dt('2011-10-24 16:31:40'), dt('2011-10-24 18:53:19')): 329,
+                (dt('2011-10-24 18:53:20'), dt('2011-10-24 21:14:59')): 1099,
+                (dt('2011-10-24 21:15:00'), dt('2011-10-24 23:36:39')): 1014,
+                (dt('2011-10-24 23:36:40'), dt('2011-10-24 23:59:59')): 76,
+            }
+        }
+        self.log_analyzer.do_cmd("url-hits-per-time --filter '/ice/m_menu\.htm$' --step 8500")
+        self.assertEqual(self.log_analyzer._hpuput.aggr_data, expected_data)
 
-    def test_HitsPerIPPerUnitTime(self):
-        expected_data = (
-            ('68.171.231.80', ('2011-10-24:00:00:00', '2011-10-24:00:59:59'), 47),
-            ('68.171.231.80', ('2011-10-24:01:00:00', '2011-10-24:01:59:59'), 42),
-            ('68.171.231.80', ('2011-10-24:02:00:00', '2011-10-24:02:59:59'), 31),
-            ('68.171.231.80', ('2011-10-24:03:00:00', '2011-10-24:03:59:59'), 19),
-            ('68.171.231.80', ('2011-10-24:04:00:00', '2011-10-24:04:59:59'), 10),
-            ('68.171.231.80', ('2011-10-24:05:00:00', '2011-10-24:05:59:59'), 15),
-            ('68.171.231.80', ('2011-10-24:06:00:00', '2011-10-24:06:59:59'), 31),
-            ('68.171.231.80', ('2011-10-24:07:00:00', '2011-10-24:07:59:59'), 49),
-            ('68.171.231.80', ('2011-10-24:08:00:00', '2011-10-24:08:59:59'), 40),
-            ('68.171.231.80', ('2011-10-24:09:00:00', '2011-10-24:09:59:59'), 58),
-            ('68.171.231.80', ('2011-10-24:10:00:00', '2011-10-24:10:59:59'), 64),
-            ('68.171.231.80', ('2011-10-24:11:00:00', '2011-10-24:11:59:59'), 49),
-            ('68.171.231.80', ('2011-10-24:12:00:00', '2011-10-24:12:59:59'), 53),
-            ('68.171.231.80', ('2011-10-24:13:00:00', '2011-10-24:13:59:59'), 55),
-            ('68.171.231.80', ('2011-10-24:14:00:00', '2011-10-24:14:59:59'), 49),
-            ('68.171.231.80', ('2011-10-24:15:00:00', '2011-10-24:15:59:59'), 32),
-            ('68.171.231.80', ('2011-10-24:16:00:00', '2011-10-24:16:59:59'), 35),
-            ('68.171.231.80', ('2011-10-24:17:00:00', '2011-10-24:17:59:59'), 58),
-            ('68.171.231.80', ('2011-10-24:18:00:00', '2011-10-24:18:59:59'), 81),
-            ('68.171.231.80', ('2011-10-24:19:00:00', '2011-10-24:19:59:59'), 316),
-            ('68.171.231.80', ('2011-10-24:20:00:00', '2011-10-24:20:59:59'), 553),
-            ('68.171.231.80', ('2011-10-24:21:00:00', '2011-10-24:21:59:59'), 653),
-            ('68.171.231.80', ('2011-10-24:22:00:00', '2011-10-24:22:59:59'), 340),
-            ('68.171.231.80', ('2011-10-24:23:00:00', '2011-10-24:23:59:59'), 136),
-        )
-        self._test_HitsPerXPerUnitTime('HitsPerIPPerUnitTime', expected_data, step=3600,
-                                       re_filter='^68.171.231.80$', expected_keys=1)
-
-        expected_data = (
-            ('67.195.112.115', ('2011-10-24:00:00:00', '2011-10-24:00:59:59'), 100),
-            ('67.195.112.115', ('2011-10-24:01:00:00', '2011-10-24:01:59:59'), 192),
-            ('67.195.112.115', ('2011-10-24:02:00:00', '2011-10-24:02:59:59'), 103),
-            ('67.195.112.115', ('2011-10-24:03:00:00', '2011-10-24:03:59:59'), 149),
-            ('67.195.112.115', ('2011-10-24:04:00:00', '2011-10-24:04:59:59'), 152),
-            ('67.195.112.115', ('2011-10-24:05:00:00', '2011-10-24:05:59:59'), 186),
-            ('67.195.112.115', ('2011-10-24:06:00:00', '2011-10-24:06:59:59'), 176),
-            ('67.195.112.115', ('2011-10-24:07:00:00', '2011-10-24:07:59:59'), 250),
-            ('67.195.112.115', ('2011-10-24:08:00:00', '2011-10-24:08:59:59'), 195),
-            ('67.195.112.115', ('2011-10-24:09:00:00', '2011-10-24:09:59:59'), 166),
-            ('67.195.112.115', ('2011-10-24:10:00:00', '2011-10-24:10:59:59'), 124),
-            ('67.195.112.115', ('2011-10-24:11:00:00', '2011-10-24:11:59:59'), 43),
-            ('67.195.112.115', ('2011-10-24:12:00:00', '2011-10-24:12:59:59'), 45),
-            ('67.195.112.115', ('2011-10-24:13:00:00', '2011-10-24:13:59:59'), 116),
-            ('67.195.112.115', ('2011-10-24:14:00:00', '2011-10-24:14:59:59'), 114),
-            ('67.195.112.115', ('2011-10-24:15:00:00', '2011-10-24:15:59:59'), 88),
-            ('67.195.112.115', ('2011-10-24:16:00:00', '2011-10-24:16:59:59'), 54),
-            ('67.195.112.115', ('2011-10-24:17:00:00', '2011-10-24:17:59:59'), 41),
-            ('67.195.112.115', ('2011-10-24:18:00:00', '2011-10-24:18:59:59'), 58),
-            ('67.195.112.115', ('2011-10-24:19:00:00', '2011-10-24:19:59:59'), 65),
-            ('67.195.112.115', ('2011-10-24:20:00:00', '2011-10-24:20:59:59'), 52),
-            ('67.195.112.115', ('2011-10-24:21:00:00', '2011-10-24:21:59:59'), 46),
-            ('67.195.112.115', ('2011-10-24:22:00:00', '2011-10-24:22:59:59'), 48),
-            ('67.195.112.115', ('2011-10-24:23:00:00', '2011-10-24:23:59:59'), 232),
-            ('66.249.72.196', ('2011-10-24:00:00:00', '2011-10-24:00:59:59'), 74),
-            ('66.249.72.196', ('2011-10-24:01:00:00', '2011-10-24:01:59:59'), 92),
-            ('66.249.72.196', ('2011-10-24:02:00:00', '2011-10-24:02:59:59'), 143),
-            ('66.249.72.196', ('2011-10-24:03:00:00', '2011-10-24:03:59:59'), 94),
-            ('66.249.72.196', ('2011-10-24:04:00:00', '2011-10-24:04:59:59'), 135),
-            ('66.249.72.196', ('2011-10-24:05:00:00', '2011-10-24:05:59:59'), 161),
-            ('66.249.72.196', ('2011-10-24:06:00:00', '2011-10-24:06:59:59'), 153),
-            ('66.249.72.196', ('2011-10-24:07:00:00', '2011-10-24:07:59:59'), 166),
-            ('66.249.72.196', ('2011-10-24:08:00:00', '2011-10-24:08:59:59'), 185),
-            ('66.249.72.196', ('2011-10-24:09:00:00', '2011-10-24:09:59:59'), 182),
-            ('66.249.72.196', ('2011-10-24:10:00:00', '2011-10-24:10:59:59'), 201),
-            ('66.249.72.196', ('2011-10-24:11:00:00', '2011-10-24:11:59:59'), 116),
-            ('66.249.72.196', ('2011-10-24:12:00:00', '2011-10-24:12:59:59'), 209),
-            ('66.249.72.196', ('2011-10-24:13:00:00', '2011-10-24:13:59:59'), 155),
-            ('66.249.72.196', ('2011-10-24:14:00:00', '2011-10-24:14:59:59'), 166),
-            ('66.249.72.196', ('2011-10-24:15:00:00', '2011-10-24:15:59:59'), 122),
-            ('66.249.72.196', ('2011-10-24:16:00:00', '2011-10-24:16:59:59'), 125),
-            ('66.249.72.196', ('2011-10-24:17:00:00', '2011-10-24:17:59:59'), 98),
-            ('66.249.72.196', ('2011-10-24:18:00:00', '2011-10-24:18:59:59'), 128),
-            ('66.249.72.196', ('2011-10-24:19:00:00', '2011-10-24:19:59:59'), 111),
-            ('66.249.72.196', ('2011-10-24:20:00:00', '2011-10-24:20:59:59'), 109),
-            ('66.249.72.196', ('2011-10-24:21:00:00', '2011-10-24:21:59:59'), 118),
-            ('66.249.72.196', ('2011-10-24:22:00:00', '2011-10-24:22:59:59'), 113),
-            ('66.249.72.196', ('2011-10-24:23:00:00', '2011-10-24:23:59:59'), 75),
-        )
-        self._test_HitsPerXPerUnitTime('HitsPerIPPerUnitTime', expected_data, step=3600,
-                                       re_filter='^(?:67.195.112.115|66.249.72.196)$', expected_keys=2)
-
-        expected_data = (
-            ('208.92.36.12', ('2011-10-24:00:00:00', '2011-10-24:01:23:19'), 1),
-            ('208.92.36.12', ('2011-10-24:01:23:20', '2011-10-24:02:46:39'), 3),
-            ('208.92.36.12', ('2011-10-24:02:46:40', '2011-10-24:04:09:59'), 1),
-            ('208.92.36.12', ('2011-10-24:05:33:20', '2011-10-24:06:56:39'), 1),
-            ('208.92.36.12', ('2011-10-24:06:56:40', '2011-10-24:08:19:59'), 1),
-            ('208.92.36.12', ('2011-10-24:08:20:00', '2011-10-24:09:43:19'), 2),
-            ('208.92.36.12', ('2011-10-24:09:43:20', '2011-10-24:11:06:39'), 4),
-            ('208.92.36.12', ('2011-10-24:11:06:40', '2011-10-24:12:29:59'), 5),
-            ('208.92.36.12', ('2011-10-24:12:30:00', '2011-10-24:13:53:19'), 2),
-            ('208.92.36.12', ('2011-10-24:13:53:20', '2011-10-24:15:16:39'), 3),
-            ('208.92.36.12', ('2011-10-24:16:40:00', '2011-10-24:18:03:19'), 2),
-            ('208.92.36.12', ('2011-10-24:18:03:20', '2011-10-24:19:26:39'), 2),
-            ('208.92.36.12', ('2011-10-24:19:26:40', '2011-10-24:20:49:59'), 2),
-            ('208.92.36.12', ('2011-10-24:20:50:00', '2011-10-24:22:13:19'), 3),
-            ('208.92.36.12', ('2011-10-24:22:13:20', '2011-10-24:23:36:39'), 3),
-            ('208.92.36.12', ('2011-10-24:23:36:40', '2011-10-24:23:59:59'), 1),
-            ('208.92.36.18', ('2011-10-24:00:00:00', '2011-10-24:01:23:19'), 90),
-            ('208.92.36.18', ('2011-10-24:01:23:20', '2011-10-24:02:46:39'), 81),
-            ('208.92.36.18', ('2011-10-24:02:46:40', '2011-10-24:04:09:59'), 184),
-            ('208.92.36.18', ('2011-10-24:04:10:00', '2011-10-24:05:33:19'), 158),
-            ('208.92.36.18', ('2011-10-24:05:33:20', '2011-10-24:06:56:39'), 32),
-            ('208.92.36.18', ('2011-10-24:06:56:40', '2011-10-24:08:19:59'), 55),
-            ('208.92.36.18', ('2011-10-24:08:20:00', '2011-10-24:09:43:19'), 195),
-            ('208.92.36.18', ('2011-10-24:09:43:20', '2011-10-24:11:06:39'), 81),
-            ('208.92.36.18', ('2011-10-24:11:06:40', '2011-10-24:12:29:59'), 68),
-            ('208.92.36.18', ('2011-10-24:12:30:00', '2011-10-24:13:53:19'), 82),
-            ('208.92.36.18', ('2011-10-24:13:53:20', '2011-10-24:15:16:39'), 107),
-            ('208.92.36.18', ('2011-10-24:15:16:40', '2011-10-24:16:39:59'), 133),
-            ('208.92.36.18', ('2011-10-24:16:40:00', '2011-10-24:18:03:19'), 78),
-            ('208.92.36.18', ('2011-10-24:18:03:20', '2011-10-24:19:26:39'), 71),
-            ('208.92.36.18', ('2011-10-24:19:26:40', '2011-10-24:20:49:59'), 73),
-            ('208.92.36.18', ('2011-10-24:20:50:00', '2011-10-24:22:13:19'), 217),
-            ('208.92.36.18', ('2011-10-24:22:13:20', '2011-10-24:23:36:39'), 69),
-            ('208.92.36.18', ('2011-10-24:23:36:40', '2011-10-24:23:59:59'), 19),
-        )
-        self._test_HitsPerXPerUnitTime('HitsPerIPPerUnitTime', expected_data, step=5000,
-                                       re_filter='^208.92.36', expected_keys=2)
+    def test_HitsPerIPPerUnitTime3600(self):
+        expected_data = {
+            '67.195.112.115': { 'hits': 2795,
+                (dt('2011-10-24 00:00:00'), dt('2011-10-24 00:59:59')): 100,
+                (dt('2011-10-24 01:00:00'), dt('2011-10-24 01:59:59')): 192,
+                (dt('2011-10-24 02:00:00'), dt('2011-10-24 02:59:59')): 103,
+                (dt('2011-10-24 03:00:00'), dt('2011-10-24 03:59:59')): 149,
+                (dt('2011-10-24 04:00:00'), dt('2011-10-24 04:59:59')): 152,
+                (dt('2011-10-24 05:00:00'), dt('2011-10-24 05:59:59')): 186,
+                (dt('2011-10-24 06:00:00'), dt('2011-10-24 06:59:59')): 176,
+                (dt('2011-10-24 07:00:00'), dt('2011-10-24 07:59:59')): 250,
+                (dt('2011-10-24 08:00:00'), dt('2011-10-24 08:59:59')): 195,
+                (dt('2011-10-24 09:00:00'), dt('2011-10-24 09:59:59')): 166,
+                (dt('2011-10-24 10:00:00'), dt('2011-10-24 10:59:59')): 124,
+                (dt('2011-10-24 11:00:00'), dt('2011-10-24 11:59:59')): 43,
+                (dt('2011-10-24 12:00:00'), dt('2011-10-24 12:59:59')): 45,
+                (dt('2011-10-24 13:00:00'), dt('2011-10-24 13:59:59')): 116,
+                (dt('2011-10-24 14:00:00'), dt('2011-10-24 14:59:59')): 114,
+                (dt('2011-10-24 15:00:00'), dt('2011-10-24 15:59:59')): 88,
+                (dt('2011-10-24 16:00:00'), dt('2011-10-24 16:59:59')): 54,
+                (dt('2011-10-24 17:00:00'), dt('2011-10-24 17:59:59')): 41,
+                (dt('2011-10-24 18:00:00'), dt('2011-10-24 18:59:59')): 58,
+                (dt('2011-10-24 19:00:00'), dt('2011-10-24 19:59:59')): 65,
+                (dt('2011-10-24 20:00:00'), dt('2011-10-24 20:59:59')): 52,
+                (dt('2011-10-24 21:00:00'), dt('2011-10-24 21:59:59')): 46,
+                (dt('2011-10-24 22:00:00'), dt('2011-10-24 22:59:59')): 48,
+                (dt('2011-10-24 23:00:00'), dt('2011-10-24 23:59:59')): 232,
+            }
+        }
+        self.log_analyzer.do_cmd("ip-hits-per-time --filter ^67.195.112.115$")
+        self.assertEqual(self.log_analyzer._hpiput.aggr_data, expected_data)
 
+    def test_HitsPerIPPerUnitTime3598(self):
+        expected_data = {
+            '66.249.72.196': { 'hits': 3231,
+                (dt('2011-10-24 00:00:00'), dt('2011-10-24 00:59:58')): 74,
+                (dt('2011-10-24 00:59:59'), dt('2011-10-24 01:59:57')): 92,
+                (dt('2011-10-24 01:59:58'), dt('2011-10-24 02:59:56')): 143,
+                (dt('2011-10-24 02:59:57'), dt('2011-10-24 03:59:55')): 94,
+                (dt('2011-10-24 03:59:56'), dt('2011-10-24 04:59:54')): 135,
+                (dt('2011-10-24 04:59:55'), dt('2011-10-24 05:59:53')): 161,
+                (dt('2011-10-24 05:59:54'), dt('2011-10-24 06:59:52')): 153,
+                (dt('2011-10-24 06:59:53'), dt('2011-10-24 07:59:51')): 166,
+                (dt('2011-10-24 07:59:52'), dt('2011-10-24 08:59:50')): 185,
+                (dt('2011-10-24 08:59:51'), dt('2011-10-24 09:59:49')): 181,
+                (dt('2011-10-24 09:59:50'), dt('2011-10-24 10:59:48')): 202,
+                (dt('2011-10-24 10:59:49'), dt('2011-10-24 11:59:47')): 116,
+                (dt('2011-10-24 11:59:48'), dt('2011-10-24 12:59:46')): 209,
+                (dt('2011-10-24 12:59:47'), dt('2011-10-24 13:59:45')): 155,
+                (dt('2011-10-24 13:59:46'), dt('2011-10-24 14:59:44')): 166,
+                (dt('2011-10-24 14:59:45'), dt('2011-10-24 15:59:43')): 122,
+                (dt('2011-10-24 15:59:44'), dt('2011-10-24 16:59:42')): 125,
+                (dt('2011-10-24 16:59:43'), dt('2011-10-24 17:59:41')): 97,
+                (dt('2011-10-24 17:59:42'), dt('2011-10-24 18:59:40')): 128,
+                (dt('2011-10-24 18:59:41'), dt('2011-10-24 19:59:39')): 111,
+                (dt('2011-10-24 19:59:40'), dt('2011-10-24 20:59:38')): 110,
+                (dt('2011-10-24 20:59:39'), dt('2011-10-24 21:59:37')): 118,
+                (dt('2011-10-24 21:59:38'), dt('2011-10-24 22:59:36')): 113,
+                (dt('2011-10-24 22:59:37'), dt('2011-10-24 23:59:35')): 74,
+                (dt('2011-10-24 23:59:36'), dt('2011-10-24 23:59:59')): 1,
+            }
+        }
+        self.log_analyzer.do_cmd("ip-hits-per-time --filter ^66.249.72.196$ --step 3599")
+        self.assertEqual(self.log_analyzer._hpiput.aggr_data, expected_data)
 
-    def test_HitsPerUrlByTimeToRenderLinear(self):
-        expected_data = (
-           ('www.nhl.com/ice/m_scores.htm', (0, 100), 21810),
-           ('www.nhl.com/ice/m_scores.htm', (100, 200), 143),
-           ('www.nhl.com/ice/m_scores.htm', (200, 300), 10),
-           ('www.nhl.com/ice/m_scores.htm', (400, 500), 2),
-           ('www.nhl.com/ice/m_scores.htm', (1900, 2000), 1),
-           ('www.nhl.com/ice/m_scores.htm', (2800, 2900), 1),
-        )
-        self._test_HitsPerXByTimeToRenderLinear('HitsPerUrlByTimeToRenderLinear', expected_data,
-                                                ms_step=100, re_filter='^www.nhl.com/ice/m_scores.htm$',
-                                                expected_keys=1)
+    def test_HitsPerUrlByTimeToRenderLinear500(self):
+        expected_data = {
+            'www.nhl.com/ice/search.htm': { 'hits': 3044,
+                (0, 500):     3040,
+                (500, 1000):  2,
+                (1000, 1500): 1,
+                (2000, 2500): 1,
+            }
+        }
+        self.log_analyzer.do_cmd("url-time-to-render --filter '^www.nhl.com/ice/search.htm$'")
+        self.assertEqual(self.log_analyzer._hpubttrl.aggr_data, expected_data)
 
-        expected_data = (
-           ('www.nhl.com/ice/search.htm', (0, 300), 3038),
-           ('www.nhl.com/ice/search.htm', (300, 600), 2),
-           ('www.nhl.com/ice/search.htm', (600, 900), 2),
-           ('www.nhl.com/ice/search.htm', (900, 1200), 1),
-           ('www.nhl.com/ice/search.htm', (2100, 2400), 1),
-        )
-        self._test_HitsPerXByTimeToRenderLinear('HitsPerUrlByTimeToRenderLinear', expected_data,
-                                                ms_step=300, re_filter='^www.nhl.com/ice/search.htm$',
-                                                expected_keys=1)
+    def test_HitsPerUrlByTimeToRenderLinear50(self):
+        expected_data = {
+            'www.nhl.com/ice/m_teams.htm': { 'hits': 833,
+                (0, 10):   590,
+                (10, 20):  70,
+                (20, 30):  151,
+                (30, 40):  11,
+                (40, 50):  1,
+                (50, 60):  1,
+                (60, 70):  7,
+                (70, 80):  1,
+                (90, 100): 1,
+            }
+        }
+        self.log_analyzer.do_cmd("url-time-to-render --filter '^www.nhl.com/ice/m_teams.htm$' --step 10")
+        self.assertEqual(self.log_analyzer._hpubttrl.aggr_data, expected_data)
 
-    def test_HitsPerIPByTimeToRenderLinear(self):
-        expected_data = (
-           ('208.92.36.18', (0, 50), 1007),
-           ('208.92.36.18', (50, 100), 394),
-           ('208.92.36.18', (100, 150), 32),
-           ('208.92.36.18', (150, 200), 4),
-           ('208.92.36.18', (250, 300), 70),
-           ('208.92.36.18', (300, 350), 20),
-           ('208.92.36.18', (350, 400), 5),
-           ('208.92.36.18', (400, 450), 18),
-           ('208.92.36.18', (450, 500), 33),
-           ('208.92.36.18', (500, 550), 52),
-           ('208.92.36.18', (550, 600), 20),
-           ('208.92.36.18', (600, 650), 12),
-           ('208.92.36.18', (650, 700), 15),
-           ('208.92.36.18', (700, 750), 15),
-           ('208.92.36.18', (750, 800), 13),
-           ('208.92.36.18', (800, 850), 9),
-           ('208.92.36.18', (850, 900), 9),
-           ('208.92.36.18', (900, 950), 18),
-           ('208.92.36.18', (950, 1000), 15),
-           ('208.92.36.18', (1000, 1050), 8),
-           ('208.92.36.18', (1050, 1100), 8),
-           ('208.92.36.18', (1100, 1150), 6),
-           ('208.92.36.18', (1150, 1200), 3),
-           ('208.92.36.18', (1200, 1250), 3),
-           ('208.92.36.18', (1300, 1350), 2),
-           ('208.92.36.18', (1500, 1550), 1),
-           ('208.92.36.18', (1950, 2000), 1),
-        )
-        self._test_HitsPerXByTimeToRenderLinear('HitsPerIPByTimeToRenderLinear', expected_data,
-                                                ms_step=50, re_filter='^208.92.36.18$', expected_keys=1)
+    def test_HitsPerIPByTimeToRenderLinear500(self):
+        expected_data = {
+            '194.158.197.10': { 'hits': 2095,
+                (0, 500):     2092,
+                (3000, 3500): 1,
+                (4000, 4500): 2,
+            }
+        }
+        self.log_analyzer.do_cmd("ip-time-to-render --filter '^194.158.197.10$'")
+        self.assertEqual(self.log_analyzer._hpibttrl.aggr_data, expected_data)
 
-        expected_data = (
-           ('204.101.237.139', (0, 75), 2283),
-           ('204.101.237.139', (75, 150), 156),
-           ('204.101.237.139', (150, 225), 87),
-           ('204.101.237.139', (225, 300), 48),
-           ('204.101.237.139', (300, 375), 11),
-           ('204.101.237.139', (375, 450), 5),
-           ('204.101.237.139', (450, 525), 7),
-           ('204.101.237.139', (525, 600), 5),
-           ('204.101.237.139', (600, 675), 2),
-           ('204.101.237.139', (675, 750), 5),
-           ('204.101.237.139', (750, 825), 2),
-           ('204.101.237.139', (825, 900), 6),
-           ('204.101.237.139', (900, 975), 4),
-           ('204.101.237.139', (975, 1050), 4),
-           ('204.101.237.139', (1050, 1125), 1),
-           ('204.101.237.139', (1125, 1200), 4),
-        )
-        self._test_HitsPerXByTimeToRenderLinear('HitsPerIPByTimeToRenderLinear', expected_data,
-                                                ms_step=75, re_filter='^204.101.237.139$', expected_keys=1)
+    def test_HitsPerIPByTimeToRenderLinear10(self):
+        expected_data = {
+            '68.171.231.81': { 'hits': 1460,
+                (0, 10):      203,
+                (10, 20):     163,
+                (20, 30):     287,
+                (30, 40):     223,
+                (40, 50):     177,
+                (50, 60):     116,
+                (60, 70):     82,
+                (70, 80):     55,
+                (80, 90):     25,
+                (90, 100):    19,
+                (100, 110):   12,
+                (110, 120):   13,
+                (120, 130):   8,
+                (130, 140):   12,
+                (140, 150):   4,
+                (150, 160):   7,
+                (160, 170):   3,
+                (170, 180):   4,
+                (180, 190):   4,
+                (190, 200):   4,
+                (200, 210):   3,
+                (210, 220):   5,
+                (220, 230):   4,
+                (230, 240):   3,
+                (240, 250):   5,
+                (250, 260):   5,
+                (260, 270):   2,
+                (270, 280):   1,
+                (310, 320):   2,
+                (320, 330):   1,
+                (340, 350):   1,
+                (360, 370):   1,
+                (470, 480):   1,
+                (520, 530):   1,
+                (670, 680):   1,
+                (830, 840):   1,
+                (880, 890):   1,
+                (1040, 1050): 1,
+            }
+        }
+        self.log_analyzer.do_cmd("ip-time-to-render --filter '^68.171.231.81$' --step 10")
+        self.assertEqual(self.log_analyzer._hpibttrl.aggr_data, expected_data)
 
 if __name__ == '__main__':
     TESTDIR = os.path.dirname(os.path.abspath(__file__))