1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
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 General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 class abstract_quality_check(object):
29 # #This float have to store the rating of the module.
30 # #Used to compute the final score (average of all scores).
33 # #This char have to store the result.
34 # #Used to display the result of the test.
37 # #This char have to store the result with more details.
38 # #Used to provide more details if necessary.
41 # #This bool defines if the test can be run only if the module is installed.
42 # #True => the module have to be installed.
43 # #False => the module can be uninstalled.
44 # bool_installed_only = True
48 this method should initialize the var
50 #This float have to store the rating of the module.
51 #Used to compute the final score (average of all scores).
54 #This char have to store the result.
55 #Used to display the result of the test.
58 #This char have to store the result with more details.
59 #Used to provide more details if necessary.
60 self.result_details = ""
62 #This bool defines if the test can be run only if the module is installed.
63 #True => the module have to be installed.
64 #False => the module can be uninstalled.
65 self.bool_installed_only = True
67 # raise 'Not Implemented'
69 def run_test(self, cr, uid, module_path=""):
71 this method should do the test and fill the score, result and result_details var
73 # raise 'Not Implemented'
75 def get_objects(self, cr, uid, module):
76 # This function returns all object of the given module..
77 pool = pooler.get_pool(cr.dbname)
78 ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module), ('model','=','ir.model')])
80 model_data = pool.get('ir.model.data').browse(cr, uid, ids2)
81 for model in model_data:
82 model_list.append(model.res_id)
84 for mod in pool.get('ir.model').browse(cr, uid, model_list):
85 obj_list.append(str(mod.model))
88 def get_ids(self, cr, uid, object_list):
89 #This method return dictionary with ids of records of object for module
90 pool = pooler.get_pool(cr.dbname)
92 for obj in object_list:
93 ids = pool.get(obj).search(cr, uid, [])
97 def format_table(self, test='', header=[], data_list=[]):
101 detail += "\n===Method Test===\n"
102 detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') % (header[0].ljust(40), header[1].ljust(16), header[2].ljust(20), header[3].ljust(16))
103 for res in data_list[1][0]:
104 detail += ('\n|-\n| %s \n| %s \n| %s \n| %s ') % (res, data_list[1][0][res][0], data_list[1][0][res][1], data_list[1][0][res][2])
105 res_format['summary'] = [data_list[0][0]]
106 res_format['detail'] = [detail + '\n|}']
108 res_format['summary'] = data_list[0]
109 res_format['detail'] = data_list[1]
112 detail += "\n===Speed Test===\n"
113 detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s') % (header[0].ljust(40), header[1].ljust(10), header[2].ljust(10), header[3].ljust(10), header[4].ljust(10), header[5].ljust(20))
114 for data in data_list[1]:
115 detail += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (data[0], data[1], data[2], data[3], data[4], data[5])
116 res_format['summary'] = data_list[0]
117 res_format['detail'] = [detail + '\n|}\n']
122 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: