Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/tests/propertiestests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/tutorius/tests/propertiestests.py')
-rw-r--r--src/sugar/tutorius/tests/propertiestests.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/sugar/tutorius/tests/propertiestests.py b/src/sugar/tutorius/tests/propertiestests.py
index 52a9a75..45ba264 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):
@@ -286,6 +294,8 @@ class TBooleanPropertyTest(unittest.TestCase):
def test_basic_boolean(self):
assert self.prop.value == False, "Could not set initial value via constructor"
+ assert self.prop.type == "boolean", "Wrong type for TBooleanProperty : %s"%self.prop.type
+
self.prop.set(True)
assert self.prop.value == True, "Could not change the value via set"
@@ -313,6 +323,8 @@ class TEnumPropertyTest(unittest.TestCase):
def test_basic_enum(self):
assert self.prop.value == "hello", "Could not set initial value on property"
+ assert self.prop.type == "enum", "Wrong type for TEnumProperty : %s"%self.prop.type
+
self.prop.set(True)
assert self.prop.value, "Could not change the value via set"
@@ -333,6 +345,8 @@ class TFilePropertyTest(unittest.TestCase):
def test_basic_file(self):
assert self.prop.value == "propertiestests.py", "Could not set initial value"
+ assert self.prop.type == "file", "Wrong type for TFileProperty : %s"%self.prop.type
+
self.prop.set("run-tests.py")
assert self.prop.value == "run-tests.py", "Could not change value"