Exemplo n.º 1
0
 def test_count(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         expected_count = self.route_counters[url]
         real_count = row["count"]
         self.assertEqual(expected_count, real_count)
Exemplo n.º 2
0
 def test_time_sum(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         expected_time_sum = self.time_sum[url]
         real_time_sum = row["time_sum"]
         delta = abs(expected_time_sum - real_time_sum)
         self.assertLess(delta, self.assertion_delta)
Exemplo n.º 3
0
 def test_count_perc(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         expected_perc = (self.route_counters[url] / self.total_requests_count) * 100
         expected_perc = round(expected_perc, ndigits=3)
         real_perc = row["count_perc"]
         self.assertEqual(expected_perc, real_perc)
Exemplo n.º 4
0
 def test_time_max(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         values = self.time_values[url]
         expected_max_value = max(values)
         real_max_value = row["time_max"]
         delta = abs(expected_max_value - real_max_value)
         self.assertLess(delta, self.assertion_delta)
Exemplo n.º 5
0
 def test_time_avg(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         values = self.time_values[url]
         expected_avg = round(sum(values) / len(values), ndigits=3)
         real_avg = row["time_avg"]
         delta = abs(expected_avg - real_avg)
         self.assertLess(delta, self.assertion_delta)
Exemplo n.º 6
0
 def test_time_perc(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         expected_time_perc = (self.time_sum[url] / self.total_time_sum) * 100
         expected_time_perc = round(expected_time_perc, ndigits=3)
         real_time_perc = row["time_perc"]
         delta = abs(expected_time_perc - real_time_perc)
         self.assertLess(delta, self.assertion_delta)
Exemplo n.º 7
0
 def test_time_med(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     for row in result:
         url = row["url"]
         values = self.time_values[url]
         values.sort(reverse=True)
         len_values = len(values)
         central_index = len_values // 2
         if len_values % 2 != 0:
             expected_med = values[central_index]
         else:
             val_1 = values[central_index]
             val_2 = values[central_index - 1]
             expected_med = (val_1 + val_2) / 2
         real_med = row["time_med"]
         delta = abs(expected_med - real_med)
         self.assertLess(delta, self.assertion_delta)
Exemplo n.º 8
0
 def test_errors_counter(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         *_, errors = log_analyzer.get_statistics(tuple())
     self.assertEqual(self.errors_count, errors)
Exemplo n.º 9
0
 def test_total_rows_counter(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         _, total_rows, _ = log_analyzer.get_statistics(tuple())
     self.assertEqual(self.total_rows_count, total_rows)
Exemplo n.º 10
0
 def test_split_by_url(self):
     with patch(self.request_params, return_value=self.mocked_requests):
         result, *_ = log_analyzer.get_statistics(tuple())
     self.assertEqual(len(result), len(self.route_counters.keys()))