- assert sum(s.share for s in e.splits) == e.amount,\
- "Total of splits is not the same as the expenditure total"
+ self.assertEqual(sum(s.share for s in e.splits), e.amount)
+
+ def test_splitDistribution(self):
+ user_count = meta.Session.query(model.User).count()
+ for e in meta.Session.query(model.Expenditure):
+ even_total = (e.amount / user_count) * user_count
+ difference = abs(even_total - e.amount)
+ self.assert_(std_dev(list(int(s.share) for s in e.splits)) <= difference, \
+ "Expenditure doesn't appear to be evenly distributed")