<!DOCTYPE html>
<html>
<body>
    <div class="navbar-header" style = " background-color: rgb(255, 255, 255); margin:0; padding:0;">
        <img src = "https://github.com/eclipse/kiso-testing/raw/master/docs/images/pykiso_logo.png" alt = "Pykiso report" width="15%" height="15%">
    </div>
    {# For each TestClass #}
    {% for class_name, class_content in ALL_STEP_REPORT.items() %}
        <hr>
        <div class="col-12 text-left">
            {# Add Title and description #}
            <h2>ITF Test Report for:  <a href="{{class_content["file_path"]}}">{{class_name}}</a>
            {% if class_content["succeed"] %}
                -> [<div style="color:green;">Success</div>]
            {% else %}
                -> [<div style="color:red;">Fail</div>]
            {% endif %}
            </h2>
            <h3>Test Description:</h3>
            <p>    {{class_content["description"] | replace("\n", "<br/>\n") }}</p>
            <h3>Date, Time, Software versions:</h3>
            <p>
            {# Add additional information from header key #}
            {% for data in [class_content["time_result"], class_content["header"]] %}
                {% for key, value in data.items() %}
                    <u>{{key}}</u>: {{value}}</br>
                {% endfor %}
            {% endfor %}
            </p>

            {# For each test (setUp, run, tearDown) #}
            {% for test_name, test_content in class_content["test_list"].items() %}
                <h3>{{test_name}}</h3>
                <table>
                    <thead>
                        <tr>
                            {# Set Columns name from the first row, excluding succeed flag #}
                            <th scope="col" style="width: 3%">Step</th>
                            {% for column_name in test_content[0].keys() if column_name != "succeed" %}
                                <th scope="col">{{column_name}}</th>
                            {% endfor %}
                        </tr>
                    </thead>
                    <tbody>
                        {# Loop over each assert method called (step-report) #}
                        {% for row in test_content %}
                            {# Set cell color variable according to the assert result and emptiness #}
                            {% if row.pop("succeed") %}
                                {% set color_cell = "background-color: rgb(196, 243, 196);" %}
                                {% set color_empty_cell = "background-color: rgb(250, 250, 128);" %}
                            {% else %}
                                {% set color_cell = "background-color: rgb(236, 160, 160);" %}
                                {% set color_empty_cell = "background-color: rgb(236, 160, 160);" %}
                            {% endif %}

                            <tr>
                                <th scope="row" style="{{color_cell}}" >{{loop.index}}</th>
                                {# Loop over each cell of the row #}
                                {% for col_value in row.values() %}
                                    {# Set the value and apply colors to the cell #}
                                    <td {% if (col_value or col_value == False) %} style="{{color_cell}}" {% else %} style="{{color_empty_cell}}" {% endif %}>
                                        {{col_value}}
                                    </td>
                                {% endfor %}
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% endfor %}
        </div>
    {% endfor %}
</body>
</html>

<style type="text/css">
{% include "report_template.css" %}
</style>
