def test_uses_date_range(self): metric = BytesAdded( namespaces=[0], ) assert_true(not metric.validate()) metric = BytesAdded( namespaces=[0], start_date='2013-07-01', end_date='2013-08-01', ) metric.csrf_token.data = metric.generate_csrf_token({}) assert_true(metric.validate()) results = metric(list(self.cohort), self.mwSession) dan_expected = { 'net_sum': 10, 'absolute_sum': 10, 'positive_only_sum': 10, 'negative_only_sum': 0, } assert_equal( results[self.dan_id], dan_expected, )
def test_uses_summation_options(self): metric = BytesAdded( namespaces=[0], start_date='2013-06-01', end_date='2013-08-01', positive_only_sum=False, negative_only_sum=False, ) metric.csrf_token.data = metric.generate_csrf_token({}) assert_true(metric.validate()) results = metric(list(self.cohort), self.mwSession) dan_expected = { 'net_sum': 6, 'absolute_sum': 14, } assert_equal( results[self.dan_id], dan_expected, )