mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
analytics: Fix ValueErrors affecting test coverage.
Pathways that only catch internal code errors should use AssertionError so that they are not included when computing test coverage.
This commit is contained in:
@@ -45,7 +45,7 @@ class CountStat(object):
|
||||
self.filter_args = filter_args
|
||||
self.group_by = group_by
|
||||
if frequency not in self.FREQUENCIES:
|
||||
raise ValueError("Unknown frequency: %s" % (frequency,))
|
||||
raise AssertionError("Unknown frequency: %s" % (frequency,))
|
||||
self.frequency = frequency
|
||||
self.interval = self.GAUGE if is_gauge else frequency
|
||||
self.is_logging = False
|
||||
@@ -92,7 +92,7 @@ def process_count_stat(stat, fill_to_time):
|
||||
elif fill_state.state == FillState.DONE:
|
||||
currently_filled = fill_state.end_time
|
||||
else:
|
||||
raise ValueError("Unknown value for FillState.state: %s." % (fill_state.state,))
|
||||
raise AssertionError("Unknown value for FillState.state: %s." % (fill_state.state,))
|
||||
|
||||
currently_filled = currently_filled + timedelta(hours = 1)
|
||||
while currently_filled <= fill_to_time:
|
||||
|
||||
@@ -50,10 +50,10 @@ def generate_time_series_data(days=100, business_hours_base=10, non_business_hou
|
||||
[24*non_business_hours_base] * 2
|
||||
holidays = [random() < holiday_rate for i in range(days)]
|
||||
else:
|
||||
raise ValueError("Unknown frequency: %s" % (frequency,))
|
||||
raise AssertionError("Unknown frequency: %s" % (frequency,))
|
||||
if length < 2:
|
||||
raise ValueError("Must be generating at least 2 data points. "
|
||||
"Currently generating %s" % (length,))
|
||||
raise AssertionError("Must be generating at least 2 data points. "
|
||||
"Currently generating %s" % (length,))
|
||||
growth_base = growth ** (1. / (length-1))
|
||||
values_no_noise = [seasonality[i % len(seasonality)] * (growth_base**i) for i in range(length)]
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def time_range(start, end, frequency, min_length):
|
||||
end = floor_to_day(end)
|
||||
step = timedelta(days=1)
|
||||
else:
|
||||
raise ValueError("Unknown frequency: %s" % (frequency,))
|
||||
raise AssertionError("Unknown frequency: %s" % (frequency,))
|
||||
|
||||
times = []
|
||||
if min_length is not None:
|
||||
|
||||
@@ -152,7 +152,7 @@ def table_filtered_to_id(table, key_id):
|
||||
elif table == InstallationCount:
|
||||
return InstallationCount.objects.all()
|
||||
else:
|
||||
raise ValueError("Unknown table: %s" % (table,))
|
||||
raise AssertionError("Unknown table: %s" % (table,))
|
||||
|
||||
def client_label_map(name):
|
||||
# type: (str) -> str
|
||||
@@ -191,8 +191,8 @@ def rewrite_client_arrays(value_arrays):
|
||||
def get_time_series_by_subgroup(stat, table, key_id, end_times, subgroups, labels, include_empty_subgroups):
|
||||
# type: (CountStat, Type[BaseCount], Optional[int], List[datetime], List[str], List[str], bool) -> Dict[str, List[int]]
|
||||
if len(subgroups) != len(labels):
|
||||
raise ValueError("subgroups and labels have lengths %s and %s, which are different." %
|
||||
(len(subgroups), len(labels)))
|
||||
raise AssertionError("subgroups and labels have lengths %s and %s, which are different." %
|
||||
(len(subgroups), len(labels)))
|
||||
queryset = table_filtered_to_id(table, key_id).filter(property=stat.property) \
|
||||
.values_list('subgroup', 'end_time', 'value')
|
||||
value_dicts = defaultdict(lambda: defaultdict(int)) # type: Dict[Optional[str], Dict[datetime, int]]
|
||||
|
||||
Reference in New Issue
Block a user