"""Smoke tests proving Django boots and the health endpoint responds."""

from __future__ import annotations

import pytest
from django.urls import reverse


@pytest.mark.django_db
def test_health_endpoint_ok(api_client):
    url = reverse("health")
    response = api_client.get(url)
    assert response.status_code == 200
    assert response.data["status"] == "ok"
    assert response.data["checks"]["database"] is True


@pytest.mark.django_db
def test_user_model_creates_user():
    from simorgh.apps.accounts.models import User

    user = User.objects.create_user("+989000000001", password="s3cret!!!", email="alice@example.com")
    assert user.pk is not None
    assert user.email == "alice@example.com"
    assert user.check_password("s3cret!!!")
    assert user.public_id is not None


@pytest.mark.django_db
def test_user_model_creates_superuser():
    from simorgh.apps.accounts.models import User

    admin = User.objects.create_superuser("+989000000099", password="s3cret!!!", email="root@example.com")
    assert admin.is_staff and admin.is_superuser
