Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/tests/actiontests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/tutorius/tests/actiontests.py')
-rw-r--r--src/sugar/tutorius/tests/actiontests.py45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/sugar/tutorius/tests/actiontests.py b/src/sugar/tutorius/tests/actiontests.py
index cfb6114..6001ec7 100644
--- a/src/sugar/tutorius/tests/actiontests.py
+++ b/src/sugar/tutorius/tests/actiontests.py
@@ -27,9 +27,14 @@ import gtk
from sugar.tutorius.actions import *
from sugar.tutorius.services import ObjectStore
+test_props = {"prop_a":8, "prop_b":3, "prop_c":"Hi"}
+
class PropertyAction(Action):
def __init__(self, na):
- self.a = TIntProperty(na)
+ Action.__init__(self)
+ self.prop_a = TIntProperty(test_props["prop_a"])
+ self.prop_b = TIntProperty(test_props["prop_b"])
+ self.prop_c = TStringProperty(test_props["prop_c"])
def has_function(obj, function_name):
"""
@@ -40,13 +45,16 @@ def has_function(obj, function_name):
return False
class PropsTest(unittest.TestCase):
-
def test_get_properties(self):
- prop = PropertyAction(8)
+ act = PropertyAction(8)
+
+ assert act.get_properties() == test_props.keys(), "Action does not contain property 'a'"
+
+ for prop_name in act.get_properties():
+ assert act.properties[prop_name].value == test_props[prop_name], "Wrong initial value for property %s : %s"%(prop_name,str(act.properties[prop_name]))
- assert prop.get_properties() == ['a'], "Action does not contain property 'a'"
-class OnceWrapperTest(unittest.TestCase):
+class OnceWrapperTests(unittest.TestCase):
def validate_wrapper(self, wrapper_instance):
"""
Ensures that a given instance of a wrapper implements the Action
@@ -71,9 +79,34 @@ class OnceWrapperTest(unittest.TestCase):
onceWrap = OnceWrapper(prop)
self.validate_wrapper(onceWrap)
+
+ assert onceWrap.get_properties() == test_props.keys(), "OnceWrapper should give access to properties of the contained action"
+
+class DialogMessageTest(unittest.TestCase):
+ def setUp(self):
+ self.dial = DialogMessage("Message text", [200, 300])
+
+ def test_properties(self):
+ assert self.dial.message.value == "Message text", "Wrong start value for the message"
+
+ assert self.dial.position.value == [200, 300], "Wrong start value for the position"
+
+class BubbleMessageTest(unittest.TestCase):
+ def setUp(self):
+ self.bubble = BubbleMessage(message="Message text", pos=[200, 300], tailpos=[-15, -25])
+
+ def test_properties(self):
+ props = self.bubble.get_properties()
+
+ assert "message" in props, 'No message property of BubbleMessage'
+
+ assert "position" in props, 'No position property in BubbleMessage'
+
+ assert "tail_pos" in props, 'No tail position property in BubbleMessage'
+
class CountAction(Action):
- """
+ """
This action counts how many times it's do and undo methods get called
"""
def __init__(self):