"""Auto-generated tests for {{ contract_id }} contract.

Generated by Griot scaffold on {{ generated_at }}.
Contract: {{ contract_id }}
Schemas: {{ schemas | length }}
"""
from __future__ import annotations

import pytest

{% for schema in schemas %}

# ── {{ schema.name }} ──────────────────────────────────────────────
{%- if schema.required_fields %}

class Test{{ schema.class_name }}NotNull:
    """Verify required fields are not null for {{ schema.name }}."""

    @pytest.fixture
    def df(self):
        """Load {{ schema.name }} test data.

        TODO: Replace with actual data loading.
        """
        raise NotImplementedError("Provide a DataFrame fixture for {{ schema.name }}")
{%- for field in schema.required_fields %}

    def test_{{ field.snake_name }}_not_null(self, df):
        """Field '{{ field.name }}' must not be null."""
        assert df["{{ field.name }}"].notnull().all()
{%- endfor %}
{%- endif %}

{%- if schema.unique_fields %}

class Test{{ schema.class_name }}Uniqueness:
    """Verify unique constraints for {{ schema.name }}."""

    @pytest.fixture
    def df(self):
        """Load {{ schema.name }} test data.

        TODO: Replace with actual data loading.
        """
        raise NotImplementedError("Provide a DataFrame fixture for {{ schema.name }}")
{%- for field in schema.unique_fields %}

    def test_{{ field.snake_name }}_unique(self, df):
        """Field '{{ field.name }}' must have unique values."""
        assert df["{{ field.name }}"].is_unique
{%- endfor %}
{%- endif %}

{%- if schema.quality_rules %}

class Test{{ schema.class_name }}Quality:
    """Quality rules from contract for {{ schema.name }}."""

    @pytest.fixture
    def df(self):
        """Load {{ schema.name }} test data.

        TODO: Replace with actual data loading.
        """
        raise NotImplementedError("Provide a DataFrame fixture for {{ schema.name }}")
{%- for rule in schema.quality_rules %}

    def test_{{ rule.safe_id }}(self, df):
        """Quality rule: {{ rule.id }}."""
        # TODO: implement quality check
        pass
{%- endfor %}
{%- endif %}
{% endfor %}
