From 5f261ec335872243ea296a8ac2cc77aa21310012 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 6 Sep 2012 15:47:12 -0400 Subject: [PATCH] Test that values are clamped between 0 and 100% for progresses --- common/lib/xmodule/xmodule/tests/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index f95a92397a..f2af50b416 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -704,13 +704,15 @@ class ProgressTest(unittest.TestCase): self.assertRaises(ValueError, Progress, 0, 0) self.assertRaises(ValueError, Progress, 2, 0) self.assertRaises(ValueError, Progress, 1, -2) - self.assertRaises(ValueError, Progress, 3, 2) - self.assertRaises(ValueError, Progress, -2, 5) self.assertRaises(TypeError, Progress, 0, "all") # check complex numbers just for the heck of it :) self.assertRaises(TypeError, Progress, 2j, 3) + def test_clamp(self): + self.assertEqual((2, 2), Progress(3, 2).frac()) + self.assertEqual((-2, 2), Progress(0, 2).frac()) + def test_frac(self): p = Progress(1, 2) (a, b) = p.frac()