{%- import "generator_macros.j2" as macros with context -%}
{{ macros.header(imports=['Queen']) }}

class {{ exercise | camel_case }}Test(unittest.TestCase):
{% set suite_tests = cases -%}

{%- macro test_case(case) -%}
    def test_{{ case["description"] | to_snake }}(self):
        {% if case["property"] == "canAttack" -%}
        {% set white_queen = case["input"]["white_queen"]["position"] -%}
        {% set black_queen = case["input"]["black_queen"]["position"] -%}
        {% if case is error_case -%}
        with self.assertRaises(ValueError) as err:
            Queen({{ white_queen["row"] }}, {{ white_queen["column"] }}).can_attack(Queen({{ black_queen["row"] }}, {{ black_queen["column"] }}))
        self.assertEqual(type(err.exception), ValueError)
        self.assertEqual(err.exception.args[0], "{{ case["expected"]["error"] }}")
        {% else -%}
        self.assertIs(Queen({{ white_queen["row"] }}, {{ white_queen["column"] }}).can_attack(Queen({{ black_queen["row"] }}, {{ black_queen["column"] }})), {{ case["expected"] }})
        {% endif %}
        {% else -%}
        {% set queen = case["input"]["queen"]["position"] -%}
        {% if case is error_case -%}
        with self.assertRaises(ValueError) as err:
            Queen({{ queen["row"] }}, {{ queen["column"] }})
        self.assertEqual(type(err.exception), ValueError)
        self.assertEqual(err.exception.args[0], "{{ case["expected"]["error"] }}")
        {% else -%}
        Queen({{ queen["row"] }}, {{ queen["column"] }})
        {% endif %}
        {% endif %}
{%- endmacro -%}

{% for cases in suite_tests -%}
    # {{ cases["description"] }}
    {% for case in cases["cases"] -%}
    {{ test_case(case) }}
    {% endfor %}

{% endfor %}
    {% if additional_cases | length -%}
    # Track-specific tests
    {% for case in additional_cases -%}
    {{ test_case(case) }}
    {% endfor %}
    {% endif %}
