~openerp/openobject-server/trunk-speedup-need_action-tde

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
#    
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
#
##############################################################################

#
# This script will automatically test all profiles, localisations and language
# packs You must start the OpenERP server and not have a test database. You
# may also have to change some data in the top of this file.
#

import xmlrpclib
import time
import base64

url = 'http://localhost:8069/xmlrpc'
profiles = [
    'profile_accounting',
    'profile_service',
    'profile_manufacturing'
]
l10n_charts = [
    'l10n_uk',
    False,
    'l10n_be',
    'l10n_fr'
]
dbname = 'test'
admin_passwd = 'admin'
lang = False          # List of langs of False for all


sock = xmlrpclib.ServerProxy(url+'/object')
sock2 = xmlrpclib.ServerProxy(url+'/db')
sock3 = xmlrpclib.ServerProxy(url+'/common')
sock4 = xmlrpclib.ServerProxy(url+'/wizard')
demos =  [True]

langs = lang or (map(lambda x: x[0], sock2.list_lang()) + ['en_US'])

def wait(id):
    progress=0.0
    while not progress==1.0:
        time.sleep(3)
        progress,users = sock2.get_progress(admin_passwd, id)
        time.sleep(3)
    return True

def wizard_run(wizname, fieldvalues=None, endstate='end'):
    if fieldvalues is None:
        fieldvalues = {}
    wiz_id = sock4.create(dbname, uid, 'admin', wizname)
    state = 'init'
    datas = {'form':{}}
    while state!=endstate:
        res = sock4.execute(dbname, uid, 'admin', wiz_id, datas, state, {})
        if 'datas' in res:
            datas['form'].update( res['datas'] )
        if res['type']=='form':
            for field in res['fields'].keys():
                datas['form'][field] = res['fields'][field].get('value', False)
            state = res['state'][-1][0]
            datas['form'].update(fieldvalues)
        elif res['type']=='state':
            state = res['state']
    return True

for demo in demos:
    for l10n in l10n_charts:
        print 'Testing localisation', l10n, '...'
        for prof in profiles:
            print '\tTesting profile', prof, '...'
            id = sock2.create(admin_passwd, dbname, demo, lang)
            wait(id)
            uid = sock3.login(dbname, 'admin','admin')

            idprof = sock.execute(dbname, uid, 'admin', 'ir.module.module', 'search', [('name','=',prof)])
            if l10n:
                idl10n = sock.execute(dbname, uid, 'admin', 'ir.module.module', 'search', [('name','=',l10n)])
            else:
                idl10n = [-1]
            wizard_run('base_setup.base_setup', {
                'profile': idprof[0],
                'charts': idl10n[0],
            }, 'menu')
            for lang in langs:
                print '\t\tTesting Language', lang, '...'
                wizard_run('module.lang.install', {'lang': lang})

            ok = False
            range = 4
            while (not ok) and range:
                try:
                    time.sleep(2)
                    id = sock2.drop(admin_passwd, dbname)
                    ok = True
                except:
                    range -= 1
            time.sleep(2)




# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: