Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-10-28 06:15:15 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-10-28 06:15:15 (GMT)
commit53af01c95abe622c0490b43c12439a04aa449509 (patch)
tree6e7ca498415f8e20874c1eaf7b2c19458218eeb3 /tests
parentd5e7b4d380dfa9b979071b862e67d29ec127c542 (diff)
addon test extension to check interface contraints
Diffstat (limited to 'tests')
-rw-r--r--tests/addontests.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/addontests.py b/tests/addontests.py
index 5fb4f61..24fc803 100644
--- a/tests/addontests.py
+++ b/tests/addontests.py
@@ -18,7 +18,7 @@
import unittest
-from sugar.tutorius import addon
+from sugar.tutorius import addon, properties
class AddonTest(unittest.TestCase):
def test_create_constructor_fail(self):
@@ -47,4 +47,27 @@ class AddonTest(unittest.TestCase):
def test_get_addon_meta(self):
addon._cache = None
meta = addon.get_addon_meta("BubbleMessage")
- assert meta.keys() == ['mandatory_props', 'class', 'display_name', 'name', 'icon',]
+ expected = set(['mandatory_props', 'class', 'display_name', 'name', 'type', 'icon'])
+ assert not set(meta.keys()).difference(expected), "%s == %s"%(meta.keys(), expected)
+
+ def test_reverse_lookup(self):
+ obj = addon.create("BubbleMessage", message="Hi!", position=[12,31])
+ assert "BubbleMessage" == addon.get_name_from_type(type(obj))
+
+ for name in addon.list_addons():
+ klass = addon.get_addon_meta(name)['class']
+ assert name == addon.get_name_from_type(klass),\
+ "could not reverse lookup from type '%s'"%klass.__name__
+
+ def test_addon_constructor(self):
+ for name in addon.list_addons():
+ obj = addon.create(name)
+ # __init__ can have locals, but should not initialize attributes on
+ # self as non-properties attributes won't survive serialization
+ # through DBUS. Assignation in do() for actions or install_handlers
+ # for event filters is the correct way.
+ attribs = set(obj.__dict__.keys()).difference(obj._props.keys()+['_props', '_callback'])
+ assert not attribs,\
+ "assignation of attribute(s) %s detected in '%s.__init__'"%(attribs, type(obj).__name__)
+
+