示例#1
0
def generate_heatmap_report_html(testruns, filename):
    env = get_jinja_environment()
    for testrun in testruns:
        testrun.__dict__["data"] = {}
        if is_correct_answer(testrun):
            testrun.data["heatmap_adjusted_time"] = adjust_time_for_language(testrun.get_lean_elapsed_milliseconds(), testrun.solution.language)
        else:
            testrun.data["heatmap_adjusted_time"] = None

    unique_authors = sorted(list({testrun.solution.author for testrun in testruns}))
    unique_problems = sorted(list({testrun.solution.problem.name for testrun in testruns}))

    for problem in unique_problems:
        correct_testruns_for_problem = [
            testrun
            for testrun in testruns
            if testrun.solution.problem.name == problem and is_correct_answer(testrun)
        ]
        times = sorted([
            testrun.data["heatmap_adjusted_time"]
            for testrun in correct_testruns_for_problem
        ])
        for testrun in correct_testruns_for_problem:
            testrun.data["heatmap_percentile"] = percentile(times, testrun.data["heatmap_adjusted_time"])
            testrun.data["heatmap_heat_color"] = heat_color_for_percentile(testrun.data["heatmap_percentile"])

    report_name = "Time Heatmap Report"
    report_date = time.time()

    content = env.get_template("report-heatmap.html").render(**locals())
    fileio.write_entire_file(filename, content)
示例#2
0
def test_write_entire_file_reads_same_content(sample_file_path_for_writing):
    # Arrange
    content_to_write = os.linesep.join(sample_file_lines)

    # Act
    fileio.write_entire_file(sample_file_path_for_writing, content_to_write)
    content_read = fileio.read_entire_file(sample_file_path_for_writing)

    # Assert
    assert content_read == content_to_write
示例#3
0
def generate_matrix_report_html(testruns, filename):
    env = get_jinja_environment()
    report_name = "Progress Matrix Report"
    report_date = time.time()
    legend_results = [
        TestRunCorrectAnswerResult(),
        TestRunWrongAnswerResult(),
        TestRunTimeoutResult(timeout=0),
        TestRunRuntimeErrorResult(message=None),
        TestRunFormatErrorResult(message=None),
        TestRunCompilationErrorResult(message=None),
        TestRunSolutionMissingResult(),
        TestRunInternalErrorResult(exception_info=None),
    ]
    content = env.get_template("report-matrix.html").render(**locals())
    fileio.write_entire_file(filename, content)
示例#4
0
def generate_full_log_html(testruns, filename):
    env = get_jinja_environment()
    report_name = "Solution Execution Log"
    report_date = time.time()
    content = env.get_template("report-full.html").render(**locals())
    fileio.write_entire_file(filename, content)