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.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/addontests.py b/tests/addontests.py
index 24fc803..8ea49e9 100644
--- a/tests/addontests.py
+++ b/tests/addontests.py
@@ -19,6 +19,7 @@
import unittest
from sugar.tutorius import addon, properties
+import os, sys
class AddonTest(unittest.TestCase):
def test_create_constructor_fail(self):
@@ -41,13 +42,13 @@ class AddonTest(unittest.TestCase):
assert obj is not None
def test_reload_addons(self):
- addon._cache = None
+ addon.__cache__.clear()
assert len(addon.list_addons()) > 0, "Addons should be reloaded upon cache clear"
def test_get_addon_meta(self):
- addon._cache = None
+ addon.__cache__.clear()
meta = addon.get_addon_meta("BubbleMessage")
- expected = set(['mandatory_props', 'class', 'display_name', 'name', 'type', 'icon'])
+ expected = set(['mandatory_props', 'class', 'display_name', 'name', 'ts', 'type', 'icon'])
assert not set(meta.keys()).difference(expected), "%s == %s"%(meta.keys(), expected)
def test_reverse_lookup(self):
@@ -70,4 +71,21 @@ class AddonTest(unittest.TestCase):
assert not attribs,\
"assignation of attribute(s) %s detected in '%s.__init__'"%(attribs, type(obj).__name__)
+ def test_addon_reimport(self):
+ obj = addon.create("BubbleMessage", message="Hi!", position=[12,31])
+ mod_name = type(obj).__module__
+ # alter module
+ type(obj).testvar = True
+
+ # recreate without touching the module file
+ obj = addon.create("BubbleMessage", message="Hi!", position=[12,31])
+ assert hasattr(type(obj), 'testvar') and type(obj).testvar == True
+
+ # touch the module
+ os.system('touch %s'%sys.modules.get(mod_name).__file__)
+ obj = addon.create("BubbleMessage", message="Hi!", position=[12,31])
+ mod = type(obj).__module__
+ assert not hasattr(mod, 'testvar')
+
+