diff options
| author | pso (tiny) <pso@tinyerp.com> | 2008-12-24 12:50:46 +0530 |
|---|---|---|
| committer | pso (tiny) <pso@tinyerp.com> | 2008-12-24 12:50:46 +0530 |
| commit | eaa876bb450b8c61d4f5eadc243b413914a61b43 (patch) | |
| tree | 30ec253f3d2d8db5ff6afef2dceae86ddddb7012 /addons/base_module_quality/method_test | |
| parent | 50839dcb9338d184c8a0c34e1c23e13035790523 (diff) | |
| parent | 22e08146f917b7408d4feac17be10b7f30bb038b (diff) | |
merge
bzr revid: solanki.priyesh@gmail.com-20081222065441-0wrzqih2ylonvcrr
bzr revid: pso@tinyerp.com-20081224060924-rgyj1jvh5cihcbxl
bzr revid: pso@tinyerp.com-20081224072046-4ooxerfj3rmd3sn6
Diffstat (limited to 'addons/base_module_quality/method_test')
| -rw-r--r-- | addons/base_module_quality/method_test/__init__.py | 24 | ||||
| -rw-r--r-- | addons/base_module_quality/method_test/method_test.py | 95 |
2 files changed, 119 insertions, 0 deletions
diff --git a/addons/base_module_quality/method_test/__init__.py b/addons/base_module_quality/method_test/__init__.py new file mode 100644 index 00000000000..79850888f41 --- /dev/null +++ b/addons/base_module_quality/method_test/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py new file mode 100644 index 00000000000..b89614331d2 --- /dev/null +++ b/addons/base_module_quality/method_test/method_test.py @@ -0,0 +1,95 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + + +import os +from tools import config + +from base_module_quality import base_module_quality +import pooler + +class quality_test(base_module_quality.abstract_quality_check): + + def __init__(self): + self.result = """ +===Method Test=== + +This test checks if the module classes are raising exception when calling basic methods or no. + + +""" + self.bool_installed_only = True + return None + + def run_test(self, cr, uid, module_path): + pool = pooler.get_pool(cr.dbname) + module_name = module_path.split('/')[-1] + ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module_name), ('model','=','ir.model')]) + model_list = [] + model_data = pool.get('ir.model.data').browse(cr, uid, ids2) + for model in model_data: + model_list.append(model.res_id) + obj_list = [] + for mod in pool.get('ir.model').browse(cr, uid, model_list): + obj_list.append(str(mod.model)) + result={} + ok_count = 0 + ex_count = 0 + + for obj in obj_list: + temp = [] + try: + res = pool.get(obj).search(cr, uid, []) + temp.append('Ok') + ok_count += 1 + except: + temp.append('Exception') + ex_count += 1 + try: + res1 = pool.get(obj).fields_view_get(cr, uid,) + temp.append('Ok') + ok_count += 1 + except: + temp.append('Exception') + ex_count += 1 + try: + res2 = pool.get(obj).read(cr, uid, []) + temp.append('Ok') + ok_count += 1 + except: + temp.append('Exception') + ex_count += 1 + result[obj] = temp + self.result+=('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') % ('Object Name'.ljust(40), 'search()'.ljust(16), 'fields_view_get()'.ljust(20), 'read()'.ljust(16)) + + for res in result: + self.result += ('\n|-\n| %s \n| %s \n| %s \n| %s ') % (res, result[res][0],result[res][1], result[res][2]) + + self.result += '\n|}' + print "RES", self.result + self.score = (ok_count + ex_count) and float(ok_count)/float(ok_count + ex_count) or 0.0 + + return None + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + |
