示例#1
0
    def expand_macro(self, formatter, name, text, args):
        """Execute the macro
        """
        self.env.log.debug("TestPlanMacro.expand_macro()")

        parser = TestcaseParser(self.env)

        self.env.log.debug( "name: %s", str(name))
        self.env.log.debug( "args: %s", str(args))
        self.env.log.debug( "text: %s", str(text))

        errors = list()
        # Parse config and testcases
        attrs, tcnames_and_users = TestPlanMacroParser(self.env).parse_config(text)
        self.log.debug("attrs: %s" % attrs)

        # syntax check the testcases
        for tcname, users in tcnames_and_users:
            try:
                parser.parseTestcase(tcname)
            except TracError, e:
                # FIXME: commented because auf genshi unicode error - raised
                # instead, see other FIXME below!
                #"""
                error_message = safe_unicode("Parsing error in Testcase %s:" %
                        tcname)
                errors.append(system_message(error_message,
                    text= safe_unicode(e.message)))
示例#2
0
    def _parse_xml(self, xmltree, pagename=None, version=None):
        self.dbg('TestcaseParser._parse_xml( %s, %s )' % (pagename, version))

        # it is a Testcase
        case = TestCase(self.env)
        case.version = version
        case.wiki = pagename
        case.description = ""

        # we now have paragraph, paragraph and definition list
        # which represent "title", "description" and "actions"
        for node in xmltree:

            if node.tagname not in ['paragraph', 'block_quote']:
                self.dbg('ignored: %s' % node.shortrepr())
                continue

            # set title or description
            if node.tagname == 'paragraph':
                text = self._node_text(node)

                if '=' in text:
                    self.dbg('set title: %s' % node.shortrepr())
                    case.title = text
                else:
                    # TODO - save the pararagraph or linefeed
                    self.dbg('append description: %s' % node.shortrepr())
                    case.description += text

            else:
                # we have a block_quote which can be lists

                for child in node.children:

                    if child.tagname == 'definition_list':
                        # a definition list contains our actions
                        self._parse_deflist(case, child)
                    else:
                        # all the rest will be interpreted as description
                        self.dbg('append description: %s' % child.shortrepr())
                        case.description += self._node_text(child)

        self.dbg("case: %s" % case.getattrs())

        # check testcase
        if not case.title:
            msg = safe_unicode('Testcase title is missing, please fix: %s' % xmltree.astext()[:256])
            raise TracError(msg)

        if len(case.actions) == 0:
            raise TracError(safe_unicode(
                'Testcase actions are missing, please add actions for: "%s"' %
                case.title))

        return case
示例#3
0
 def _build_configs_wiki(self, config):
     """ builds wiki formatting for the configuration table
     """
     text = u"== Testparameter ==\n||'''Attribut'''||'''Wert'''||\n"
     table = u''
     for key in config.keys():
         table += u'||%s||%s||\n' % (unicode(key), unicode(config[key]))
     return safe_unicode(text + table)
示例#4
0
 def _build_testcases_wiki(self, tcnames_and_users):
     """ builds the testcases names and users in wiki syntax
         returns wikitext
     """
     self.log.debug( "TestPlanMacro._build_testcases_wiki(%s)" % tcnames_and_users)
     text = u"\n== Zu testende Testcases ==\n||'''Testcase'''||'''User'''||\n"
     for tcname, users in tcnames_and_users:
         text += '||[wiki:%s]||%s||\n' % (tcname, ",".join(users))
     return safe_unicode(text)
示例#5
0
    def expand_macro(self, formatter, name, text, args):
        """Execute the macro
        """
        req = formatter.req
        add_stylesheet(req, "TestManager/css/jquery.jOrgChart.css")
        add_script(req, "TestManager/js/jquery.jOrgChart.js")
        add_script(req, "TestManager/js/start_org.js")

        from models import Element
        con = self._parse_macro_content(text, req)
        out = StringIO.StringIO()
        con.to_list()
        text = """{{{#!html
        <ul id='org' style='display:none'>
        %s</ul>
        <div id="chart" class="orgChart"></div>
        }}}""" % con.to_list()
        Formatter(self.env, formatter.context).format(safe_unicode(text),out)
        return Markup(out.getvalue())
示例#6
0
    def render_admin_panel(self, req, cat, page, path_info):
        """ main request handler
        """
        if not MANAGER_PERMISSION in req.perm:
            return

        #template data
        data = dict()
        data["info"] = req.args.get("info", "")
        data["warning"] = req.args.get("warning", "")
        data["error"] = req.args.get("error", "")
        # The template to be rendered
        template = 'TestManager_base.html'
        data['page'] = page
        data["testplanlink"] = req.base_url + req.path_info

        if 'start_plan' in req.args:
            # setup and start a new testrun
            pagename = req.args['start_plan']
            self.log.debug("trying to start testplan " + pagename)
            testrun = models.TestRun(self.env)
            try:
                testrun.setup(pagename, req.authname)
                testrun.start()
            except TracError as e:
                data["error"] = safe_unicode(e.message)

        elif 'testplan_to_restart' in req.args:
            # we have a defect testrun to be restarted
            runids = req.args['testplan_to_restart']

            def ensure_list(var):
                if type(var) == list:
                    return var
                else:
                    return [var]
            for runid in ensure_list(runids):
                try:
                    self.log.debug("trying to restart testplan " + runid)
                    testrun = models.TestRun(self.env, runid)
                    testrun.start()
                except TracError as e:
                    data["error"] = safe_unicode(e.message)

        # query and render accepted testruns
        runs = models.TestRunQuery(self.env, status='accepted').execute()

        # TODO: populate with TestRun model
        for run in runs:
            # from genshi.builder import tag
            #run['ref'] = tag.a('#', run['id'],
            #' ', run['summary'], href=req.href.ticket(run['id']))
            run['ref'] = tag.a(
                '#', run.id,
                ' ', run.summary,
                href=req.href.ticket(run.id)
            )

        testplans = list()
        for testplan in WikiSystem(self.env).get_pages('Testplan'):
            testplans.append(testplan)
        if len(testplans) < 1:
            data["info"] = 'There are no testplans'
        if len(runs) < 1:
            data["info"] = 'There are no running testplans'
        testplans.sort()

        # get active and valid testruns
        data["testruns"] = runs
        data["testplans"] = testplans
        # TODO: to be implemented in order to populate an already startet but brick testrun
        data["defect_runs"] = models.TestRunQuery(self.env, status='new').execute()
        for defect_run in data["defect_runs"]:
            defect_run['ref'] = tag.a('#', defect_run.id, ' ',
                    defect_run.summary, href=req.href.ticket(defect_run.id))
        data["title"] = 'TestPlans'
        return template, data