From 58634b4e8225d8434e15251b09d4be31c2c0c0d8 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sat, 19 Jul 2008 05:04:52 +0000 Subject: [PATCH] Attempt to test that splits are distributed evenly --- bluechips/tests/splits/test_random.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bluechips/tests/splits/test_random.py b/bluechips/tests/splits/test_random.py index 2f95738..0168932 100644 --- a/bluechips/tests/splits/test_random.py +++ b/bluechips/tests/splits/test_random.py @@ -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" -- 2.45.2