Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/addontests.py
blob: 5a48e42e1f94af5c283600386ed7d30f71c8b39f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright (C) 2009, Tutorius.org
# Copyright (C) 2009, Simon Poirier <simpoir@gmail.com>
#
#
# 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")
        keys = meta.keys()
        assert 'mandatory_props' in keys
        assert 'class' in keys
        assert 'display_name' in keys
        assert 'name' in keys
        assert 'icon' in keys