# 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 Order
from ali_test_2.types.api.v2.orders import TransferRetrieveResponse

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


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

    @pytest.mark.skip()
    @parametrize
    def test_method_create(self, client: AliTest2) -> None:
        transfer = client.api.v2.orders.transfers.create(
            0,
        )
        assert_matches_type(Order, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_create(self, client: AliTest2) -> None:
        response = client.api.v2.orders.transfers.with_raw_response.create(
            0,
        )

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

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

            transfer = response.parse()
            assert_matches_type(Order, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_retrieve(self, client: AliTest2) -> None:
        transfer = client.api.v2.orders.transfers.retrieve(
            transfer_id=0,
            id=0,
            x_tt_action_token="X-TT-Action-Token",
        )
        assert_matches_type(TransferRetrieveResponse, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_retrieve(self, client: AliTest2) -> None:
        response = client.api.v2.orders.transfers.with_raw_response.retrieve(
            transfer_id=0,
            id=0,
            x_tt_action_token="X-TT-Action-Token",
        )

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

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

            transfer = response.parse()
            assert_matches_type(TransferRetrieveResponse, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    def test_method_update(self, client: AliTest2) -> None:
        transfer = client.api.v2.orders.transfers.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        )
        assert_matches_type(Order, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    def test_raw_response_update(self, client: AliTest2) -> None:
        response = client.api.v2.orders.transfers.with_raw_response.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        )

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

    @pytest.mark.skip()
    @parametrize
    def test_streaming_response_update(self, client: AliTest2) -> None:
        with client.api.v2.orders.transfers.with_streaming_response.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            transfer = response.parse()
            assert_matches_type(Order, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True


class TestAsyncTransfers:
    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_create(self, async_client: AsyncAliTest2) -> None:
        transfer = await async_client.api.v2.orders.transfers.create(
            0,
        )
        assert_matches_type(Order, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_create(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.orders.transfers.with_raw_response.create(
            0,
        )

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

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

            transfer = await response.parse()
            assert_matches_type(Order, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_retrieve(self, async_client: AsyncAliTest2) -> None:
        transfer = await async_client.api.v2.orders.transfers.retrieve(
            transfer_id=0,
            id=0,
            x_tt_action_token="X-TT-Action-Token",
        )
        assert_matches_type(TransferRetrieveResponse, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_retrieve(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.orders.transfers.with_raw_response.retrieve(
            transfer_id=0,
            id=0,
            x_tt_action_token="X-TT-Action-Token",
        )

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

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

            transfer = await response.parse()
            assert_matches_type(TransferRetrieveResponse, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip()
    @parametrize
    async def test_method_update(self, async_client: AsyncAliTest2) -> None:
        transfer = await async_client.api.v2.orders.transfers.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        )
        assert_matches_type(Order, transfer, path=["response"])

    @pytest.mark.skip()
    @parametrize
    async def test_raw_response_update(self, async_client: AsyncAliTest2) -> None:
        response = await async_client.api.v2.orders.transfers.with_raw_response.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        )

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

    @pytest.mark.skip()
    @parametrize
    async def test_streaming_response_update(self, async_client: AsyncAliTest2) -> None:
        async with async_client.api.v2.orders.transfers.with_streaming_response.update(
            transfer_id=0,
            id=0,
            status="ACCEPTED",
            x_tt_action_token="X-TT-Action-Token",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            transfer = await response.parse()
            assert_matches_type(Order, transfer, path=["response"])

        assert cast(Any, response.is_closed) is True
