author David Douard <>
Fri, 14 Nov 2014 12:51:47 +0100
changeset 1740 f3137466457a
parent 1559 40234c0420e8
permissions -rw-r--r--
Big Refactoring (BR) of the test execution model Get rid of narval preprocessors in favor of Recipes - Each preprocessing recipe must be run from the "main" recipe (thus we add a ATest.exec_recipe() method that can be called from Recipe execution). - We add a (Repository, checkout_recipe, Recipe) relation, which is the Recipe that tells how to retrieve the code for a given Repository - Also add a (ProjectEnvironment, setup_recipe, Recip) dedicated to perform the installation for a project (compile and install) - Add implementations for these recipes for Python project - Rewrite the quick recipe using this new model

"""this module contains some plot report views for test execution results

:organization: Logilab
:copyright: 2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: --
:license: General Public License version 2 -
__docformat__ = "restructuredtext en"
_ = unicode

    'error': "#FF5555",
    'failure': "#FF8844",
    'partial': "#FFFF55",
    'success': "#33FF33",
    'other': "#AAAAAA",

from cubicweb.predicates import multi_columns_rset

    from cubes.jqplot.views import JQPlotSimpleView
except ImportError:
    class JQPlotTestExecutionView(JQPlotSimpleView):
        __regid__ = 'jqplot.testexecution'
        __select__ = multi_columns_rset(3)
        default_renderer = 'bar'

        onload = '''%(id)s = $.jqplot("%(id)s", %(data)s, %(options)s);

                function (ev, seriesIndex, pointIndex, data) {
                    /* To open in a NEW window use: */
                    if ( ev.which == 2 ) {
                    } else  {
                       /* To open in the same window use: */
        default_options = {
            'varyBarColor': True,
        default_legend = {
            'show': False,

        def get_data(self):
            return [[i+1,x[1],self._cw.build_url(x[0])] for i,x in enumerate(self.cw_rset.rows)]

        def set_custom_options(self, options):
            other = ERROR_CODES.get('other')
            options['seriesColors'] = [ERROR_CODES.get(x[2], other) for x in self.cw_rset.rows]
            #FIXME hack to approximate width since it doesn't work in js
            options['series'][0]['rendererOptions']['barWidth'] = 350/len(self.cw_rset.rows)

        def div_holder(self, divid, width, height):
            super(JQPlotTestExecutionView, self).div_holder(divid, width, height)
            self.w(u'''<table class="plotlegend"><tr>%s</tr></table>
            ''' % ''.join(['<td>%s</td><td style="background:%s">&nbsp;&nbsp;&nbsp;</td>' % (x,y) for x,y in  ERROR_CODES.items()]))

def registration_callback(vreg):
    if not 'jqplot' in vreg.config.cubes():
        return # don't register anything from this module
    vreg.register_all(globals().values(), __name__)