示例#1
0
def generateTestTable(baseUrl, testList, attrs):
    """Generate html code with list (table) containing tests overview and filtering links
    
    :Parameters:
        baseUrl: url to current page (without attributes). 
            Will be used as base for filtering links
        testList: iterable object containing `TestResultStorage.resultRepository.models.TestRun` instances
        attrs: attributes given to current page (will be used to generate links)
        
    :Return:
        html code (table) with tests descriptions and filtering links
            links will point to `baseUrl` giving `attrs` and filtering attr
    """
    html = "<table> \
        <tr align=\"left\">  \
          <th>Test name</th> \
          <th>Duration</th> \
          <th>Result</th> \
          <th>Project</th> \
          <th>Branch</th> \
          <th>Batch</th> \
          <th>Details</th> \
        </tr> "

    for test in testList:
        html += "<tr id=\"" + test.get_result_display() + "\">"

        html += "<td>" + generateLink(
            baseUrl,
            attrs,
            escape(test.testName),
            switchAttr=('testName', test.testName)) + "</td>"  #name
        html += "<td>" + formatDuration(test.duration) + "</td>"  #duration
        html += "<td>" + generateLink(
            baseUrl,
            attrs,
            _(test.get_result_display()),
            switchAttr=('result', test.result)) + "</td>"  #result

        html += "<td>" + generateLink(
            '/' + projectListDir, {}, str(
                test.batchId.project)) + "</td>"  #project
        html += "<td>" + str(test.batchId.branch) + "</td>"  #branch

        html += "<td>" + generateLink(
            baseUrl,
            attrs,
            str(test.batchId.id),
            switchAttr=('batch', test.batchId.id)) + "</td>"  #batch
        html += "<td>" + generateLink('/' + testDetailDir, {'test': test.id},
                                      _("Details")) + "</td>"  #details

        html += "</tr>"
    html += "</table>"
    return html
示例#2
0
def generateProjectList(projects):
    html = "<table> \
        <tr align=\"left\"> \
            <th>Name</th> \
            <th>Repository</th> \
        </tr>"
    for project in projects:
        html += "<tr>"
        html += "<td>" + project.projectName + "</td>"
        html += "<td>" + generateLink(project.sourceRepositoryUrl, None, project.sourceRepositoryUrl) + "</td>"
        html += "<td>" + generateLink("/" + batchListDir, {'project' : project.id}, "Show batches") + "</td>"
        html += "</tr>"
    html += "</table"
    return html
示例#3
0
def generateProjectList(projects):
    html = "<table> \
        <tr align=\"left\"> \
            <th>Name</th> \
            <th>Repository</th> \
        </tr>"

    for project in projects:
        html += "<tr>"
        html += "<td>" + project.projectName + "</td>"
        html += "<td>" + generateLink(project.sourceRepositoryUrl, None,
                                      project.sourceRepositoryUrl) + "</td>"
        html += "<td>" + generateLink("/" + batchListDir,
                                      {'project': project.id},
                                      "Show batches") + "</td>"
        html += "</tr>"
    html += "</table"
    return html
示例#4
0
def generateTestTable(baseUrl, testList, attrs):
    """Generate html code with list (table) containing tests overview and filtering links
    
    :Parameters:
        baseUrl: url to current page (without attributes). 
            Will be used as base for filtering links
        testList: iterable object containing `TestResultStorage.resultRepository.models.TestRun` instances
        attrs: attributes given to current page (will be used to generate links)
        
    :Return:
        html code (table) with tests descriptions and filtering links
            links will point to `baseUrl` giving `attrs` and filtering attr
    """
    html = "<table> \
        <tr align=\"left\">  \
          <th>Test name</th> \
          <th>Duration</th> \
          <th>Result</th> \
          <th>Project</th> \
          <th>Branch</th> \
          <th>Batch</th> \
          <th>Details</th> \
        </tr> "
    for test in testList:
        html += "<tr id=\"" + test.get_result_display() + "\">"
        
        html += "<td>" + generateLink(baseUrl, attrs, escape(test.testName),
                        switchAttr = ('testName', test.testName)) + "</td>" #name
        html += "<td>" + formatDuration(test.duration) + "</td>" #duration
        html += "<td>" + generateLink(baseUrl, attrs, _(test.get_result_display()),
                        switchAttr = ('result', test.result)) + "</td>" #result
        
        html += "<td>" + generateLink('/' + projectListDir, {}, str(test.batchId.project)) + "</td>" #project
        html += "<td>" + str(test.batchId.branch) + "</td>" #branch
        
        html += "<td>" + generateLink(baseUrl, attrs, str(test.batchId.id),
                        switchAttr = ('batch', test.batchId.id)) + "</td>" #batch
        html += "<td>" + generateLink('/' + testDetailDir, {'test' : test.id}, _("Details")) + "</td>" #details
        
        html += "</tr>"
    html += "</table>"
    return html
示例#5
0
def generateTestDescription(test):
    """Generate html code describing test object
    
    :Parameters:
        test: `TestResultStorage.resultRepository.models.TestRun` instance
        
    :Return:
        html code (table) describing given object.
    """
    html = "<table>"
    html += "<tr><td>Name</td>"
    html += "<td>" + escape(test.testName) + "</td></tr>"

    html += "<tr valign=\"top\"><td>Description</td>"
    html += "<td>" + escape(str(test.description)) + "</td></tr>"

    html += "<tr><td>Start time</td>"
    html += "<td>" + str(test.startTime) + "</td></tr>"

    html += "<tr><td>Duration</td>"
    html += "<td>" + formatDuration(test.duration) + "</td></tr>"

    html += "<tr><td>Batch</td>"
    html += "<td>" + str(test.batchId) + "</td></tr>"

    html += "<tr><td>Result</td>"
    html += "<td>" + test.get_result_display() + "</td></tr>"
    html += "<tr><td>Repository path</td>"
    html += "<td>" + test.sourceRepositoryPath + "</td></tr>"
    data = TestRunData.objects.filter(runId=test.id)
    for item in data:
        if item.errText:
            html += "<tr valign=\"top\"><td>Error</td>"
            html += "<td>" + escape(item.errText) + "</td></tr>"
        if item.backtrace:
            html += "<tr valign=\"top\"><td>Backtrace</td>"
            html += "<td>"
            try:
                backtrace = pickle.loads(item.backtrace)
                for line in backtrace:
                    html += escape(line) + "<br/>"
            except:
                html += "Can't load - invalid database format"
            html += "</td></tr>"
        if item.dumpFile:
            html += "<tr valign=\"top\"><td>Snapshot</td>"
            html += "<td>" + generateLink(
                baseUrl="/" + dataDir + "/" + escape(item.dumpFile),
                attrs=None,
                name=escape(item.dumpFile)) + "</td></tr>"
    html += "</table>"
    return html
示例#6
0
def generateTestDescription(test):
    """Generate html code describing test object
    
    :Parameters:
        test: `TestResultStorage.resultRepository.models.TestRun` instance
        
    :Return:
        html code (table) describing given object.
    """
    html = "<table>"
    html += "<tr><td>Name</td>"
    html += "<td>" + escape(test.testName) + "</td></tr>"
    
    html += "<tr valign=\"top\"><td>Description</td>"
    html += "<td>" + escape(str(test.description)) + "</td></tr>"
    
    html += "<tr><td>Start time</td>"
    html += "<td>" + str(test.startTime) + "</td></tr>"
    
    html += "<tr><td>Duration</td>"
    html += "<td>" + formatDuration(test.duration) + "</td></tr>"
    
    html += "<tr><td>Batch</td>"
    html += "<td>" + str(test.batchId) + "</td></tr>"
    
    html += "<tr><td>Result</td>"
    html += "<td>" + test.get_result_display() + "</td></tr>"
    html += "<tr><td>Repository path</td>"
    html += "<td>" + test.sourceRepositoryPath + "</td></tr>"
    data = TestRunData.objects.filter(runId = test.id)
    for item in data:
        if item.errText:
            html += "<tr valign=\"top\"><td>Error</td>"
            html += "<td>" + escape(item.errText) + "</td></tr>"
        if item.backtrace:
            html += "<tr valign=\"top\"><td>Backtrace</td>"
            html += "<td>"
            try:
                backtrace = pickle.loads(item.backtrace)
                for line in backtrace:
                    html += escape(line) + "<br/>"
            except:
                html += "Can't load - invalid database format"
            html += "</td></tr>"
        if item.dumpFile:
            html += "<tr valign=\"top\"><td>Snapshot</td>"
            html += "<td>" + generateLink(baseUrl = "/" + dataDir + "/" + escape(item.dumpFile),
                                                attrs = None, name = escape(item.dumpFile)) + "</td></tr>"
    html += "</table>"
    return html
示例#7
0
def generateBatchTable(baseUrl, batchList, attrs):
    """Generate html code with list (table) containing batch overview and filtering links
    
    :Parameters:
        baseUrl: url to current page (without attributes). 
            Will be used as base for filtering links
        batchList: iterable object containing `TestResultStorage.resultRepository.models.BatchRun` instances
        attrs: attributes given to current page (will be used to generate links)
        
    :Return:
        html code (table) with batches descriptions and filtering links
            links will point to `baseUrl` giving `attrs` and filtering attr
    """
    html = ' \
    <table> \
        <tr align="left"> \
          <th>Project</th> \
          <th>Branch</th> \
          <th>Rev</th> \
          <th>Host</th> \
          <th>Start time</th> \
          <th>Duration</th> \
          <th>Batch</th> \
          <th>Finished</th> \
          <th>Result</th> \
          <th>Tests</th> \
        </tr> '
    for batch in batchList:
        html += "<tr id=\"" + batch.get_result_display() + "\">"
        html += "<td>" + generateLink(baseUrl, attrs, batch.project.projectName,
                        switchAttr = ('project', batch.project.id)) + "</td>" #project
        html += "<td>" + generateLink(baseUrl, attrs, batch.branch,
                        switchAttr = ('branch', batch.branch)) + "</td>" #branch
        if batch.repositoryRevision:
            html += "<td>" + generateLink(baseUrl, attrs, str(batch.repositoryRevision),
                        switchAttr = ('revision', batch.repositoryRevision)) + "</td>" #revision
        else:
            html += "<td>" + str(batch.repositoryRevision) + "</td>" #revision
        html += "<td>" + generateLink(baseUrl, attrs, batch.machineName,
                        switchAttr = ('host', batch.machineName)) + "</td>" #host
        html += "<td>" + str(batch.startTime) + "</td>" #startTime
        if batch.duration:
            html += "<td>" + formatDuration(batch.duration) + "</td>" #duration
        else:
            html += "<td>Unknown</td>" #duration
        html += "<td>" + str(batch.id) + "&nbsp;" + \
                        generateLink('/' + batchDetailDir, {'batch' : batch.id},
                        "Detail") + "</td>" #batch
        html += "<td>" + generateLink(baseUrl, attrs, str(batch.hasFinished == 1),
                        switchAttr = ('hasFinished', batch.hasFinished)) + "</td>" #hasFinished
        html += "<td>" + generateLink(baseUrl, attrs, batch.get_result_display(),
                        switchAttr = ('result', batch.result)) + "</td>" #result
        if batch.hasFinished:
            testCount = batch.testCount
        else:
            testCount = TestRun.objects.filter( batchId = batch.id).count()
        if testCount:
            html += "<td>" + generateLink('/' + testListDir, {'batch' : batch.id },
                        str(testCount)) + "</td>" #testCount
        else:
            html += "<td>0</td>"

        html += "</tr>"
    html += "</table>"
    return html