summaryrefslogtreecommitdiff
path: root/addons/base_module_quality/method_test
diff options
context:
space:
mode:
authorNajlaâ EL KHAYAT <nel@tinyerp.com>2009-01-09 11:35:45 +0100
committerNajlaâ EL KHAYAT <nel@tinyerp.com>2009-01-09 11:35:45 +0100
commitbdedbedb6271c36eb216df367d35a6e8de07c12d (patch)
tree03caba86457da29175b517cdef5b8103f69eaf67 /addons/base_module_quality/method_test
parent02de8a94c797e589b23f2ed0557920a1bde5f324 (diff)
parent74a6e4000e1187e14af2387283f66e9808b04be7 (diff)
merge
bzr revid: nel@tinyerp.com-20090109103545-22glgy373aeohcai
Diffstat (limited to 'addons/base_module_quality/method_test')
-rw-r--r--addons/base_module_quality/method_test/__init__.py2
-rw-r--r--addons/base_module_quality/method_test/method_test.py60
2 files changed, 27 insertions, 35 deletions
diff --git a/addons/base_module_quality/method_test/__init__.py b/addons/base_module_quality/method_test/__init__.py
index 79850888f41..cfc1f614751 100644
--- a/addons/base_module_quality/method_test/__init__.py
+++ b/addons/base_module_quality/method_test/__init__.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py
index c788d4bc979..34841dd41cc 100644
--- a/addons/base_module_quality/method_test/method_test.py
+++ b/addons/base_module_quality/method_test/method_test.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
@@ -20,9 +20,7 @@
#
##############################################################################
-
-import os
-from tools import config
+from tools.translate import _
from base_module_quality import base_module_quality
import pooler
@@ -30,63 +28,57 @@ 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.
-
-"""
+ super(quality_test, self).__init__()
+ self.name = _("Method Test")
+ self.note = _("""
+This test checks if the module classes are raising exception when calling basic methods or not.
+""")
self.bool_installed_only = True
+ self.ponderation = 1.0
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={}
+ obj_list = self.get_objects(cr, uid, module_name)
ok_count = 0
ex_count = 0
-
+ result_dict = {}
for obj in obj_list:
- temp = []
+ temp = [obj]
try:
res = pool.get(obj).search(cr, uid, [])
- temp.append('Ok')
+ temp.append(_('Ok'))
ok_count += 1
except:
- temp.append('Exception')
+ temp.append(_('Exception'))
ex_count += 1
try:
res1 = pool.get(obj).fields_view_get(cr, uid,)
- temp.append('Ok')
+ temp.append(_('Ok'))
ok_count += 1
except:
- temp.append('Exception')
+ temp.append(_('Exception'))
ex_count += 1
try:
res2 = pool.get(obj).read(cr, uid, [])
- temp.append('Ok')
+ temp.append(_('Ok'))
ok_count += 1
except:
- temp.append('Exception')
+ 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|}'
+ result_dict[obj] = temp
self.score = (ok_count + ex_count) and float(ok_count)/float(ok_count + ex_count) or 0.0
+ self.result = self.get_result(result_dict)
return None
+ def get_result(self, dict):
+ header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ', [_('Object Name'), 'search()', 'fields_view_get()', 'read()'])
+ detail = ""
+ if not self.error:
+ detail += self.format_table(header, dict)
+ return detail
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: