2
# Copyright (C) 2010 Canonical Ltd
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
""" Generate a basic test for each application listed in
18
/usr/share/applications/desktop.en_US.utf8.cache
20
The basic test launches the application, wait for 3 seconds then closes it
23
from re import sub, search
6
26
DESKTOPCACHE = "/usr/share/applications/desktop.en_US.utf8.cache"
7
BLACKLIST = [] # List of sections to skip
28
#: List of sections to skip. This must be a valid regular expression
29
# We must exclude window managers to not kill ourselves
30
BLACKLIST = ['metacity', 'compiz', 'unity' ]
9
33
config = ConfigParser.ConfigParser()
10
34
config.read( DESKTOPCACHE )
12
36
sections = config.sections()
15
for section in config.sections():
16
if section in BLACKLIST: continue
39
for section in sorted(config.sections()):
41
if search(v, section): continue
19
44
binary = config.get( section, 'TryExec' )
26
name = sub('\W', '', config.get( section, 'Name' ))
51
name = sub('\W', '', config.get( section, 'Name' ).capitalize())
27
52
terminal = config.get( section, 'Terminal' )
28
53
categories = config.get( section, 'Categories' ).split(';')
30
if terminal == True: continue
55
# Skip Terminal applications
56
if terminal == 'true': continue
31
57
except ConfigParser.NoOptionError:
34
60
binary = binary.split(' ')[0]
62
if binary in BINARIES: continue
63
BINARIES.append(binary)
37
66
class Test%s(TestCase):
40
def test_minimal(self):
69
def test_%s_basic(self):
41
71
self.assertTrue(True)
72
""" % (name, binary, sub('\W', '', os.path.basename(binary)))
44
74
# Generate the testcase script. You need to redirect to a file named
45
75
# test_sanitychecks.py to run it with mago
46
76
print """# This file was generated by %s
47
77
from mago import TestCase