Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/tests
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-04-06 02:38:10 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-04-16 00:52:40 (GMT)
commit0cad6dc96afc2ebd4d03beb14ed01bc155dfa322 (patch)
treed86b51b031aa5da74d3d7935020e468fa6ab4919 /src/sugar/tutorius/tests
parentaefa4024904ec92034d108d94768a388e8f1a9f6 (diff)
LP 348570 Core : Extending actions with the new properties, adding min /
max size to arrays
Diffstat (limited to 'src/sugar/tutorius/tests')
-rw-r--r--src/sugar/tutorius/tests/actiontests.py13
-rw-r--r--src/sugar/tutorius/tests/constraintstests.py38
-rw-r--r--src/sugar/tutorius/tests/propertiestests.py34
-rwxr-xr-xsrc/sugar/tutorius/tests/run-tests.py2
4 files changed, 56 insertions, 31 deletions
diff --git a/src/sugar/tutorius/tests/actiontests.py b/src/sugar/tutorius/tests/actiontests.py
index d1de5fd..cfb6114 100644
--- a/src/sugar/tutorius/tests/actiontests.py
+++ b/src/sugar/tutorius/tests/actiontests.py
@@ -29,15 +29,7 @@ from sugar.tutorius.services import ObjectStore
class PropertyAction(Action):
def __init__(self, na):
- self._a = na
-
- def set_a(self, na):
- self._a = na
-
- def get_a(self):
- return self._a
-
- a = property(fget=get_a, fset=set_a)
+ self.a = TIntProperty(na)
def has_function(obj, function_name):
"""
@@ -54,6 +46,7 @@ class PropsTest(unittest.TestCase):
assert prop.get_properties() == ['a'], "Action does not contain property 'a'"
+class OnceWrapperTest(unittest.TestCase):
def validate_wrapper(self, wrapper_instance):
"""
Ensures that a given instance of a wrapper implements the Action
@@ -67,7 +60,7 @@ class PropsTest(unittest.TestCase):
assert has_function(wrapper_instance, "get_properties"),\
"The wrapper does not have the 'get_properties' function."
-
+
def test_once_wrapper_interface(self):
"""
Tests that the interface of the OnceWrapper actually conforms to the of
diff --git a/src/sugar/tutorius/tests/constraintstests.py b/src/sugar/tutorius/tests/constraintstests.py
index 407cc24..b7b0a47 100644
--- a/src/sugar/tutorius/tests/constraintstests.py
+++ b/src/sugar/tutorius/tests/constraintstests.py
@@ -77,28 +77,50 @@ class LowerLimitConstraintTest(unittest.TestCase):
except LowerLimitConstraintError:
assert True, "Validation of LowerLimit(10) on 20 should not raise an exception"
-class SizeConstraintTest(unittest.TestCase):
+class MaxSizeConstraintTest(unittest.TestCase):
def test_empty_constraint(self):
- cons = SizeConstraint(None)
+ cons = MaxSizeConstraint(None)
try:
cons.validate(20)
- except SizeConstraintError:
+ except MaxSizeConstraintError:
assert False, "Empty contraint should not raise an exception"
def test_validate(self):
- cons = SizeConstraint(10)
+ cons = MaxSizeConstraint(10)
try:
cons.validate(range(0, 20))
- assert False, "Validation of SizeLimit(10) on list of length 20 should raise an exception"
- except SizeConstraintError:
+ assert False, "Validation of MaxSizeConstraint(10) on list of length 20 should raise an exception"
+ except MaxSizeConstraintError:
pass
try:
cons.validate(range(0,5))
- except SizeConstraintError:
- assert True, "Validation of SizeLimit(10) on list of length 5 should not raise an exception"
+ except MaxSizeConstraintError:
+ assert True, "Validation of MaxSizeConstraint(10) on list of length 5 should not raise an exception"
+class MinSizeConstraintTest(unittest.TestCase):
+ def test_empty_constraint(self):
+ cons = MinSizeConstraint(None)
+ try:
+ cons.validate(20)
+ except MinSizeConstraintError:
+ assert False, "Empty contraint should not raise an exception"
+
+ def test_validate(self):
+ cons = MinSizeConstraint(10)
+
+ try:
+ cons.validate(range(0, 5))
+ assert False, "Validation of MinSizeConstraint(10) on list of length 20 should raise an exception"
+ except MinSizeConstraintError:
+ pass
+
+ try:
+ cons.validate(range(0,20))
+ except MinSizeConstraintError:
+ assert True, "Validation of MinSizeConstraint(10) on list of length 5 should not raise an exception"
+
class ColorConstraintTest(unittest.TestCase):
def test_validate(self):
cons = ColorConstraint()
diff --git a/src/sugar/tutorius/tests/propertiestests.py b/src/sugar/tutorius/tests/propertiestests.py
index 52a9a75..b54f849 100644
--- a/src/sugar/tutorius/tests/propertiestests.py
+++ b/src/sugar/tutorius/tests/propertiestests.py
@@ -204,7 +204,7 @@ class TStringPropertyTest(unittest.TestCase):
try:
prop.set("My string is too big!")
assert False, "String should not set to longer than max size"
- except SizeConstraintError:
+ except MaxSizeConstraintError:
pass
except:
assert False, "Wrong exception type thrown"
@@ -218,7 +218,7 @@ class TStringPropertyTest(unittest.TestCase):
try:
prop = TStringProperty("This is normal", 5)
assert False, "Creation of the property should fail."
- except SizeConstraintError:
+ except MaxSizeConstraintError:
pass
except:
assert False, "Wrong exception type on failed constructor"
@@ -236,26 +236,34 @@ class TArrayPropertyTest(unittest.TestCase):
try_wrong_values(prop)
- def test_size_limit(self):
- prop = TArrayProperty([1,2], 4)
+ def test_size_limits(self):
+ prop = TArrayProperty([1,2], None, 4)
try:
prop.set([1,2,4,5,6,7])
- assert False, "Size limit constraint was not properly applied"
- except SizeConstraintError:
+ assert False, "Maximum size limit constraint was not properly applied"
+ except MaxSizeConstraintError:
+ pass
+
+ prop = TArrayProperty([1,2,3,4], 2)
+
+ try:
+ prop.set([1])
+ assert False, "Minimum size limit constraint was not properly applied"
+ except MinSizeConstraintError:
pass
- except:
- assert False, "Wrong type of exception thrown"
-
def test_failing_constructor(self):
try:
- prop = TArrayProperty([100, 0, 20], 2)
+ prop = TArrayProperty([100, 0, 20], None, 2)
assert False, "Creation of the property should fail."
- except SizeConstraintError:
+ except MaxSizeConstraintError:
+ pass
+ try:
+ prop = TArrayProperty([100, 0, 20], 4, None)
+ assert False, "Creation of the property should fail."
+ except MinSizeConstraintError:
pass
- except:
- assert False, "Wrong exception type on failed constructor"
class TColorPropertyTest(unittest.TestCase):
def test_basic_color(self):
diff --git a/src/sugar/tutorius/tests/run-tests.py b/src/sugar/tutorius/tests/run-tests.py
index 63a8de1..bf5a57e 100755
--- a/src/sugar/tutorius/tests/run-tests.py
+++ b/src/sugar/tutorius/tests/run-tests.py
@@ -69,5 +69,7 @@ if __name__=='__main__':
from linear_creatortests import *
from uamtests import *
from filterstests import *
+ from constraintstests import *
+ from propertiestests import *
unittest.main()