# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import os
from typing import Any, cast

import pytest

from ali_test_2 import AliTest2, AsyncAliTest2
from tests.utils import assert_matches_type
from ali_test_2._utils import parse_date
from ali_test_2.types.api.v2 import (
    Show,
    RushSettings,
    ShowListResponse,
    ShowRetrieveDealsResponse,
)

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")


class TestShows:
    parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve(self, client: AliTest2) -> None:
        show = client.api.v2.shows.retrieve(
            show_id=0,
        )
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_with_all_params(self, client: AliTest2) -> None:
        show = client.api.v2.shows.retrieve(
            show_id=0,
            embed="embed",
            include_showtimes_with_no_inventory="includeShowtimesWithNoInventory",
        )
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve(self, client: AliTest2) -> None:
        response = client.api.v2.shows.with_raw_response.retrieve(
            show_id=0,
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = response.parse()
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_streaming_response_retrieve(self, client: AliTest2) -> None:
        with client.api.v2.shows.with_streaming_response.retrieve(
            show_id=0,
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = response.parse()
            assert_matches_type(Show, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_list(self, client: AliTest2) -> None:
        show = client.api.v2.shows.list()
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_method_list_with_all_params(self, client: AliTest2) -> None:
        show = client.api.v2.shows.list(
            id="id",
            are_access_programs_active=True,
            are_regular_tickets_available=True,
            categories="categories",
            date=parse_date("2019-12-27"),
            date_from={},
            date_to={},
            day_part="MATINEE",
            end_date_from={},
            end_date_to={},
            fieldset="SHOW_SUMMARY",
            genres="genres",
            has_no_fees=True,
            hide_from_hero_list=True,
            include_aggregations=True,
            limit=0,
            location=0,
            max_price=0,
            num_tickets=0,
            offset=0,
            on_sale_date_from={},
            on_sale_date_to={},
            query="query",
            relevance="CATEGORY",
            sort_by="ALLOCATION",
            sort_order="ASC",
            start_date_from={},
            start_date_to={},
            subcategories="subcategories",
            use_override_fields=True,
        )
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_list(self, client: AliTest2) -> None:
        response = client.api.v2.shows.with_raw_response.list()

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = response.parse()
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_streaming_response_list(self, client: AliTest2) -> None:
        with client.api.v2.shows.with_streaming_response.list() as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = response.parse()
            assert_matches_type(ShowListResponse, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_deals(self, client: AliTest2) -> None:
        show = client.api.v2.shows.retrieve_deals(
            location_id="locationId",
        )
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_deals_with_all_params(self, client: AliTest2) -> None:
        show = client.api.v2.shows.retrieve_deals(
            location_id="locationId",
            dates="dates",
            quantity="quantity",
            timezone="timezone",
        )
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve_deals(self, client: AliTest2) -> None:
        response = client.api.v2.shows.with_raw_response.retrieve_deals(
            location_id="locationId",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = response.parse()
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_streaming_response_retrieve_deals(self, client: AliTest2) -> None:
        with client.api.v2.shows.with_streaming_response.retrieve_deals(
            location_id="locationId",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = response.parse()
            assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_rush_settings(self, client: AliTest2) -> None:
        show = client.api.v2.shows.retrieve_rush_settings(
            0,
        )
        assert_matches_type(RushSettings, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve_rush_settings(self, client: AliTest2) -> None:
        response = client.api.v2.shows.with_raw_response.retrieve_rush_settings(
            0,
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = response.parse()
        assert_matches_type(RushSettings, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_streaming_response_retrieve_rush_settings(self, client: AliTest2) -> None:
        with client.api.v2.shows.with_streaming_response.retrieve_rush_settings(
            0,
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = response.parse()
            assert_matches_type(RushSettings, show, path=["response"])

        assert cast(Any, response.is_closed) is True


class TestAsyncShows:
    parametrize = pytest.mark.parametrize(
        "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
    )

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.retrieve(
            show_id=0,
        )
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_with_all_params(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.retrieve(
            show_id=0,
            embed="embed",
            include_showtimes_with_no_inventory="includeShowtimesWithNoInventory",
        )
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_retrieve(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.shows.with_raw_response.retrieve(
            show_id=0,
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = await response.parse()
        assert_matches_type(Show, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_streaming_response_retrieve(self, async_client: AsyncAliTest2) -> None:
        async with async_client.api.v2.shows.with_streaming_response.retrieve(
            show_id=0,
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = await response.parse()
            assert_matches_type(Show, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_list(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.list()
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_method_list_with_all_params(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.list(
            id="id",
            are_access_programs_active=True,
            are_regular_tickets_available=True,
            categories="categories",
            date=parse_date("2019-12-27"),
            date_from={},
            date_to={},
            day_part="MATINEE",
            end_date_from={},
            end_date_to={},
            fieldset="SHOW_SUMMARY",
            genres="genres",
            has_no_fees=True,
            hide_from_hero_list=True,
            include_aggregations=True,
            limit=0,
            location=0,
            max_price=0,
            num_tickets=0,
            offset=0,
            on_sale_date_from={},
            on_sale_date_to={},
            query="query",
            relevance="CATEGORY",
            sort_by="ALLOCATION",
            sort_order="ASC",
            start_date_from={},
            start_date_to={},
            subcategories="subcategories",
            use_override_fields=True,
        )
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_list(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.shows.with_raw_response.list()

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = await response.parse()
        assert_matches_type(ShowListResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_streaming_response_list(self, async_client: AsyncAliTest2) -> None:
        async with async_client.api.v2.shows.with_streaming_response.list() as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = await response.parse()
            assert_matches_type(ShowListResponse, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_deals(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.retrieve_deals(
            location_id="locationId",
        )
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_deals_with_all_params(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.retrieve_deals(
            location_id="locationId",
            dates="dates",
            quantity="quantity",
            timezone="timezone",
        )
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_retrieve_deals(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.shows.with_raw_response.retrieve_deals(
            location_id="locationId",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = await response.parse()
        assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_streaming_response_retrieve_deals(self, async_client: AsyncAliTest2) -> None:
        async with async_client.api.v2.shows.with_streaming_response.retrieve_deals(
            location_id="locationId",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = await response.parse()
            assert_matches_type(ShowRetrieveDealsResponse, show, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_rush_settings(self, async_client: AsyncAliTest2) -> None:
        show = await async_client.api.v2.shows.retrieve_rush_settings(
            0,
        )
        assert_matches_type(RushSettings, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_retrieve_rush_settings(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.shows.with_raw_response.retrieve_rush_settings(
            0,
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        show = await response.parse()
        assert_matches_type(RushSettings, show, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_streaming_response_retrieve_rush_settings(self, async_client: AsyncAliTest2) -> None:
        async with async_client.api.v2.shows.with_streaming_response.retrieve_rush_settings(
            0,
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            show = await response.parse()
            assert_matches_type(RushSettings, show, path=["response"])

        assert cast(Any, response.is_closed) is True
