[IMP] posbox: print the homepage url on the status ticket
[odoo/odoo.git] / history / check_profile_l10n_all.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #    
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19 #
20 ##############################################################################
21
22 #
23 # This script will automatically test all profiles, localisations and language
24 # packs You must start the OpenERP server and not have a test database. You
25 # may also have to change some data in the top of this file.
26 #
27
28 import xmlrpclib
29 import time
30 import base64
31
32 url = 'http://localhost:8069/xmlrpc'
33 profiles = [
34     'profile_accounting',
35     'profile_service',
36     'profile_manufacturing'
37 ]
38 l10n_charts = [
39     'l10n_uk',
40     False,
41     'l10n_be',
42     'l10n_fr'
43 ]
44 dbname = 'test'
45 admin_passwd = 'admin'
46 lang = False          # List of langs of False for all
47
48
49 sock = xmlrpclib.ServerProxy(url+'/object')
50 sock2 = xmlrpclib.ServerProxy(url+'/db')
51 sock3 = xmlrpclib.ServerProxy(url+'/common')
52 sock4 = xmlrpclib.ServerProxy(url+'/wizard')
53 demos =  [True]
54
55 langs = lang or (map(lambda x: x[0], sock2.list_lang()) + ['en_US'])
56
57 def wait(id):
58     progress=0.0
59     while not progress==1.0:
60         time.sleep(3)
61         progress,users = sock2.get_progress(admin_passwd, id)
62         time.sleep(3)
63     return True
64
65 def wizard_run(wizname, fieldvalues=None, endstate='end'):
66     if fieldvalues is None:
67         fieldvalues = {}
68     wiz_id = sock4.create(dbname, uid, 'admin', wizname)
69     state = 'init'
70     datas = {'form':{}}
71     while state!=endstate:
72         res = sock4.execute(dbname, uid, 'admin', wiz_id, datas, state, {})
73         if 'datas' in res:
74             datas['form'].update( res['datas'] )
75         if res['type']=='form':
76             for field in res['fields'].keys():
77                 datas['form'][field] = res['fields'][field].get('value', False)
78             state = res['state'][-1][0]
79             datas['form'].update(fieldvalues)
80         elif res['type']=='state':
81             state = res['state']
82     return True
83
84 for demo in demos:
85     for l10n in l10n_charts:
86         print 'Testing localisation', l10n, '...'
87         for prof in profiles:
88             print '\tTesting profile', prof, '...'
89             id = sock2.create(admin_passwd, dbname, demo, lang)
90             wait(id)
91             uid = sock3.login(dbname, 'admin','admin')
92
93             idprof = sock.execute(dbname, uid, 'admin', 'ir.module.module', 'search', [('name','=',prof)])
94             if l10n:
95                 idl10n = sock.execute(dbname, uid, 'admin', 'ir.module.module', 'search', [('name','=',l10n)])
96             else:
97                 idl10n = [-1]
98             wizard_run('base_setup.base_setup', {
99                 'profile': idprof[0],
100                 'charts': idl10n[0],
101             }, 'menu')
102             for lang in langs:
103                 print '\t\tTesting Language', lang, '...'
104                 wizard_run('module.lang.install', {'lang': lang})
105
106             ok = False
107             range = 4
108             while (not ok) and range:
109                 try:
110                     time.sleep(2)
111                     id = sock2.drop(admin_passwd, dbname)
112                     ok = True
113                 except:
114                     range -= 1
115             time.sleep(2)
116
117
118
119
120 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
121