"""Generated tests for {{ directive_name }} param reconstruction."""
from __future__ import annotations

from {{ import_name }}._generated.params import build_params


class _FakeNode(dict):
    """Minimal node stub for testing build_params."""

    def __init__(self, options=None, body_text=''):
        super().__init__()
        self['h5p_options'] = options or {}
        self['_body_text'] = body_text
        self.children = []

    def astext(self):
        return self.get('_body_text', '')


class TestBuildParams:
{% for tc in test_cases %}

    def {{ tc.test_name }}(self):
{% if tc.field_type == 'boolean' %}
        node = _FakeNode({'{{ tc.option_name }}': None})
{% elif tc.field_type == 'select' %}
        node = _FakeNode({'{{ tc.option_name }}': 'test'})
{% else %}
        node = _FakeNode({'{{ tc.option_name }}': 'test_value'})
{% endif %}
        result = build_params(node)
        assert '{{ tc.param_path[0] }}' in result
{% endfor %}
{% if body_mapping %}

    def test_body(self):
        node = _FakeNode(body_text='Sample body text')
        result = build_params(node)
        assert '{{ body_mapping.param_path[0] }}' in result
{% endif %}
