Ponderations system on quality module
bzr revid: mra@tinyerp.com-20081230120110-nven6g8rirjgploi
This commit is contained in:
@@ -66,6 +66,10 @@ class abstract_quality_check(object):
|
||||
#False => the module can be uninstalled.
|
||||
self.bool_installed_only = True
|
||||
|
||||
|
||||
#This variable is use to make result of test should have more weight (Some tests are more critical than others)
|
||||
self.ponderation = 0.0
|
||||
|
||||
self.tests = []
|
||||
self.list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
|
||||
for item in self.list_folders:
|
||||
@@ -134,6 +138,9 @@ class abstract_quality_check(object):
|
||||
res_format['summary'] = data_list[0]
|
||||
return res_format
|
||||
|
||||
def add_quatation(self, x, y):
|
||||
return x/y
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -38,6 +38,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
#
|
||||
#"""
|
||||
self.bool_installed_only = True
|
||||
self.ponderation = 1.0
|
||||
return None
|
||||
|
||||
def run_test(self, cr, uid, module_path, module_state):
|
||||
@@ -84,7 +85,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
|
||||
This test checks if the module classes are raising exception when calling basic methods or no.
|
||||
|
||||
""" + "Score: " + str(self.score) + "/10\n"
|
||||
""" #+ "Score: " + str(self.score) + "/10\n"
|
||||
else:
|
||||
summary =""" \n===Method Test===:
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
#
|
||||
#"""
|
||||
self.bool_installed_only = False
|
||||
self.ponderation = 1.0
|
||||
return None
|
||||
|
||||
def run_test(self, cr, uid, module_path, module_state):
|
||||
@@ -82,7 +83,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
|
||||
This test checks if the module satisfy the current coding standard used by OpenERP.
|
||||
|
||||
""" + "Score: " + str(self.score) + "/10\n"
|
||||
""" #+ "Score: " + str(self.score) + "/10\n"
|
||||
else:
|
||||
summary =""" \n===Pylint Test===:
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
#
|
||||
#"""
|
||||
self.bool_installed_only = True
|
||||
self.ponderation = 1.0
|
||||
return None
|
||||
def run_test(self, cr, uid, module_path, module_state):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
@@ -103,7 +104,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
||||
|
||||
This test checks the speed of the module.
|
||||
|
||||
"""+ "Score: " + str(self.score) + "/10\n"
|
||||
"""#+ "Score: " + str(self.score) + "/10\n"
|
||||
else:
|
||||
summary =""" \n===Speed Test===:
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ class wiz_quality_check(osv.osv_memory):
|
||||
list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
|
||||
module_name = module_data[0].name
|
||||
abstract_obj = base_module_quality.abstract_quality_check()
|
||||
score_sum = 0.0
|
||||
ponderation_sum = 0.0
|
||||
final_score = ""
|
||||
for test in abstract_obj.tests:
|
||||
ad = tools.config['addons_path']
|
||||
if module_data[0].name == 'base':
|
||||
@@ -73,8 +76,13 @@ class wiz_quality_check(osv.osv_memory):
|
||||
module_path = os.path.join(ad, module_data[0].name)
|
||||
val = test.quality_test()
|
||||
val.run_test(cr, uid, str(module_path), str(module_data[0].state))
|
||||
string_ret += val.result['summary']
|
||||
string_detail += val.result['detail']
|
||||
string_ret += val.result['summary'] #summary tab
|
||||
string_ret += "Score: " + str(val.score) + "/10\n" #val.score = val.score * val.ponderation ???
|
||||
string_detail += val.result['detail'] # detail tab
|
||||
score_sum += (val.add_quatation(val.score, 10) * val.ponderation)
|
||||
ponderation_sum += val.ponderation
|
||||
final_score = str(score_sum / ponderation_sum * 100) + "%"
|
||||
string_ret += "\n\nPonderation Result for module:" + final_score
|
||||
self.string_detail = string_detail
|
||||
return ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user