From 5f261ec335872243ea296a8ac2cc77aa21310012 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 6 Sep 2012 15:47:12 -0400 Subject: [PATCH 1/2] 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() From 8030fdce8046b6f0c8bd6b36b697a4d5f451de66 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 6 Sep 2012 15:47:45 -0400 Subject: [PATCH 2/2] Fix test and assertion reversal in progress test --- common/lib/xmodule/xmodule/tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index f2af50b416..4103a7373e 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -711,7 +711,7 @@ class ProgressTest(unittest.TestCase): def test_clamp(self): self.assertEqual((2, 2), Progress(3, 2).frac()) - self.assertEqual((-2, 2), Progress(0, 2).frac()) + self.assertEqual((0, 2), Progress(-2, 2).frac()) def test_frac(self): p = Progress(1, 2)