diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-04-16 18:54:50 (GMT) |
---|---|---|
committer | simpoir <simpoir@gmail.com> | 2009-04-23 17:31:01 (GMT) |
commit | d66690142b643401429bfff84d42acac002e1980 (patch) | |
tree | 9a1d85532ec9e17373cac51df5ca2f988161015f /src/sugar/tutorius/tests/actiontests.py | |
parent | 78de92cde03264725093868231bdb539feb4f56b (diff) |
LP 348570 Core : Integrating properties to actions; adding tests
Diffstat (limited to 'src/sugar/tutorius/tests/actiontests.py')
-rw-r--r-- | src/sugar/tutorius/tests/actiontests.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/sugar/tutorius/tests/actiontests.py b/src/sugar/tutorius/tests/actiontests.py index ab9cdba..bce753e 100644 --- a/src/sugar/tutorius/tests/actiontests.py +++ b/src/sugar/tutorius/tests/actiontests.py @@ -27,24 +27,32 @@ 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 = na - - def set_a(self, na): - self._a = na - - def get_a(self): - return self._a - - a = property(fget=get_a, fset=set_a) - + 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): + """ + Checks whether the object has a function by that name. + """ + if hasattr(obj, function_name) and hasattr(obj.__getattribute__(function_name), "__call__"): + return True + 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 CountAction(Action): """ |