"""Tests for DomainsResource."""

from __future__ import annotations

import httpx
import pytest

from appliku import Appliku


@pytest.fixture()
def domain_data() -> dict[str, object]:
    return {"id": 1, "domain": "app.example.com", "deployment_status": "active"}


class TestDomainsList:
    def test_list_returns_paginated(
        self,
        mock_client: tuple[Appliku, list[httpx.Response]],
        domain_data: dict[str, object],
        paginated_response: object,
    ) -> None:
        client, responses = mock_client
        responses.append(httpx.Response(200, json=paginated_response([domain_data])))  # type: ignore[operator]
        result = client.domains.list("acme", 42)
        assert result.count == 1
        assert result.results[0].domain == "app.example.com"


class TestDomainsCreate:
    def test_create_returns_domain(
        self, mock_client: tuple[Appliku, list[httpx.Response]], domain_data: dict[str, object]
    ) -> None:
        client, responses = mock_client
        responses.append(httpx.Response(201, json=domain_data))
        domain = client.domains.create("acme", 42, "app.example.com")
        assert domain.id == 1
        assert domain.domain == "app.example.com"


class TestDomainsDelete:
    def test_delete_succeeds(self, mock_client: tuple[Appliku, list[httpx.Response]]) -> None:
        client, responses = mock_client
        responses.append(httpx.Response(204))
        client.domains.delete("acme", 42, 1)
