Example #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
Example #2
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
Example #3
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
Example #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
Example #5
0
def generateBatchDescription(batch):
    """Generate html code describing batch object
    
    :Parameters:
        batc: `TestResultStorage.resultRepository.models.BatchRun` instance
        
    :Return:
        html code (table) describing given object.
    """
    html = "<table> "
    '''
        <tr> \
        <th colspan=\"2\">Batch info</th> \
        </tr> \
        </tr>"
    '''
    html += '<tr><td>Start time</td>'
    html += '<td>' +  str(batch.startTime) + '</td></tr>'
    
    html += '<tr><td>Duration</td>'
    html += '<td>' + formatDuration(batch.duration) + '</td></tr>'
    
    html += '<tr><td>Result</td>'
    html += '<td>' +  batch.get_result_display() + '</td></tr>'
    
    html += '<tr><td>Finished</td>'
    html += '<td>' +  str(batch.hasFinished == 1) + '</td></tr>'
    
    html += '<tr><td>Test count</t>'
    if batch.hasFinished:
        testCount = batch.testCount
    else:
        testCount = TestRun.objects.filter(batchId = batch.id).count()
    html += '<td>' +  str(testCount) + '</td></tr>'
    
    html += '<tr><td>Project</td>'
    html += '<td>' +  batch.project.projectName + '</td></tr>'
    
    html += '<tr><td>Repository</td>'
    html += '<td>' +  batch.project.sourceRepositoryUrl + '</td></tr>'
    
    html += '<tr><td>Branch</td>'
    html += '<td>' + batch.branch + '</td></tr>'
    
    html += '<tr><td>Revision</td>'
    html += '<td>' +  str(batch.repositoryRevision) + '</td></tr>'
    
    #html += '<tr><td>Description</td>'
    #html += '<td>' +  batch.description + '</td></tr>'
    
    html += '<tr><td>Profile</td>'
    html += '<td>' +  batch.profileName + '</td></tr>'
    
    html += '<tr><td valign="top">Environment</td>'
    html += '<td>' 
    for env in batch.profileInfo.all():
        html += env.variableName + "=" + escape(env.variableValue) + "<br/>"
    html += '</td></tr>'
    
    html += '<tr><td>Host</td>'
    html += '<td>' + batch.machineName  + '</td></tr>'
    
    html += "</table>"
    return html
Example #6
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