From 940057bee6fb1ae0912e376f731a493fb964c6f2 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 05 Oct 2009 15:46:48 +0000 Subject: LP 439980 : Adding addontests.py file --- (limited to 'tests/addontests.py') diff --git a/tests/addontests.py b/tests/addontests.py new file mode 100644 index 0000000..5fb4f61 --- /dev/null +++ b/tests/addontests.py @@ -0,0 +1,50 @@ +# Copyright (C) 2009, Tutorius.org +# Copyright (C) 2009, Simon Poirier +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import unittest + +from sugar.tutorius import addon + +class AddonTest(unittest.TestCase): + def test_create_constructor_fail(self): + try: + obj = addon.create("BubbleMessage", wrong_param=True, second_wrong="This", last_wrong=12, unknown=13.4) + assert False, "Constructor with wrong parameter should raise an exception" + except: + pass + + def test_create_wrong_addon(self): + try: + obj = addon.create("Non existing addon name") + assert False, "Addon creator should raise an exception when the requested addon is unknown" + except: + pass + + def test_create(self): + obj = addon.create("BubbleMessage", message="Hi!", position=[12,31]) + + assert obj is not None + + def test_reload_addons(self): + addon._cache = None + assert len(addon.list_addons()) > 0, "Addons should be reloaded upon cache clear" + + 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',] -- cgit v0.9.1