# 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.types.api.v2 import (
    Location,
    LocationListResponse,
    LocationRetrievePrivacyLawResponse,
    LocationRetrieveGeolocationResponse,
)

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


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

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

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

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

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

            location = response.parse()
            assert_matches_type(Location, location, path=["response"])

        assert cast(Any, response.is_closed) is True

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

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

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

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

            location = response.parse()
            assert_matches_type(LocationListResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_geolocation(self, client: AliTest2) -> None:
        location = client.api.v2.locations.retrieve_geolocation()
        assert_matches_type(LocationRetrieveGeolocationResponse, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve_geolocation(self, client: AliTest2) -> None:
        response = client.api.v2.locations.with_raw_response.retrieve_geolocation()

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

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

            location = response.parse()
            assert_matches_type(LocationRetrieveGeolocationResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_geosegment(self, client: AliTest2) -> None:
        location = client.api.v2.locations.retrieve_geosegment(
            location_id=0,
        )
        assert_matches_type(str, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_geosegment_with_all_params(self, client: AliTest2) -> None:
        location = client.api.v2.locations.retrieve_geosegment(
            location_id=0,
            city="city",
            country_code="countryCode",
            country_name="countryName",
            postal_code="postalCode",
            region_code="regionCode",
            region_name="regionName",
        )
        assert_matches_type(str, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve_geosegment(self, client: AliTest2) -> None:
        response = client.api.v2.locations.with_raw_response.retrieve_geosegment(
            location_id=0,
        )

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

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

            location = response.parse()
            assert_matches_type(str, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_privacy_law(self, client: AliTest2) -> None:
        location = client.api.v2.locations.retrieve_privacy_law()
        assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve_privacy_law_with_all_params(self, client: AliTest2) -> None:
        location = client.api.v2.locations.retrieve_privacy_law(
            country_abbr="xx",
            location=0,
        )
        assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve_privacy_law(self, client: AliTest2) -> None:
        response = client.api.v2.locations.with_raw_response.retrieve_privacy_law()

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

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

            location = response.parse()
            assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True


class TestAsyncLocations:
    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:
        location = await async_client.api.v2.locations.retrieve(
            0,
        )
        assert_matches_type(Location, location, path=["response"])

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

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

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

            location = await response.parse()
            assert_matches_type(Location, location, path=["response"])

        assert cast(Any, response.is_closed) is True

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

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

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

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

            location = await response.parse()
            assert_matches_type(LocationListResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_geolocation(self, async_client: AsyncAliTest2) -> None:
        location = await async_client.api.v2.locations.retrieve_geolocation()
        assert_matches_type(LocationRetrieveGeolocationResponse, location, path=["response"])

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

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

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

            location = await response.parse()
            assert_matches_type(LocationRetrieveGeolocationResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_geosegment(self, async_client: AsyncAliTest2) -> None:
        location = await async_client.api.v2.locations.retrieve_geosegment(
            location_id=0,
        )
        assert_matches_type(str, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_geosegment_with_all_params(self, async_client: AsyncAliTest2) -> None:
        location = await async_client.api.v2.locations.retrieve_geosegment(
            location_id=0,
            city="city",
            country_code="countryCode",
            country_name="countryName",
            postal_code="postalCode",
            region_code="regionCode",
            region_name="regionName",
        )
        assert_matches_type(str, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_retrieve_geosegment(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.locations.with_raw_response.retrieve_geosegment(
            location_id=0,
        )

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

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

            location = await response.parse()
            assert_matches_type(str, location, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_privacy_law(self, async_client: AsyncAliTest2) -> None:
        location = await async_client.api.v2.locations.retrieve_privacy_law()
        assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve_privacy_law_with_all_params(self, async_client: AsyncAliTest2) -> None:
        location = await async_client.api.v2.locations.retrieve_privacy_law(
            country_abbr="xx",
            location=0,
        )
        assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

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

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

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

            location = await response.parse()
            assert_matches_type(LocationRetrievePrivacyLawResponse, location, path=["response"])

        assert cast(Any, response.is_closed) is True
