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