def stats(self): attribute_count = self.attribute_count() total_attribute_count = self.attribute_class.count_(**self.kwargs) percentage = percentize(attribute_count, total_attribute_count) reporter_ratio = make_ratio(attribute_count, self.reporters_count()) return StatsDetails(attribute_count, percentage, reporter_ratio)
def test_make_ratio(self): self.assertEqual(0.61, make_ratio(61, 100)) self.assertEqual(0.50, make_ratio(1, 2)) self.assertEqual(0, make_ratio(1, 0)) self.assertEqual(0, make_ratio(0, 0))