]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
Attempt to test that splits are distributed evenly
authorEvan Broder <broder@mit.edu>
Sat, 19 Jul 2008 05:04:52 +0000 (05:04 +0000)
committerEvan Broder <broder@mit.edu>
Sat, 19 Jul 2008 05:04:52 +0000 (05:04 +0000)
bluechips/tests/splits/test_random.py

index 2f95738f6654f02d217d5aa848a703dc2b66bc65..01689328c8856014eb6807d41e04b8324b0b70de 100644 (file)
@@ -2,6 +2,7 @@ from bluechips.tests import *
 from bluechips import model
 from bluechips.model import meta
 from bluechips.model.types import Currency
+from webhelpers.number import standard_deviation as std_dev
 import random
 
 class TestSplitRandom(TestController):
@@ -29,3 +30,9 @@ class TestSplitRandom(TestController):
         for e in meta.Session.query(model.Expenditure):
             assert sum(s.share for s in e.splits) == e.amount,\
                 "Total of splits is not the same as the expenditure total"
+    
+    def test_splitDistribution(self):
+        for e in meta.Session.query(model.Expenditure):
+            even_total = (e.amount / meta.Session.query(model.User).count())
+            assert std_dev(list(s.share for s in e.splits)) <= even_total, \
+                "Expenditure doesn't appear to be evenly distributed"