Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/addontests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/addontests.py')
-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__)
+
+