import os
import pytest
from sds_mng.setting.fetch_logistics import fetch_id, fetch_logistics
from sds_mng.util import logger


@pytest.mark.asyncio
async def test_fetch_logistics():
    token = os.environ.get("SDS_MNG_TOKEN")
    data = await fetch_id(token)

    assert "日本" in data.keys()

    # logistics = [
    #     {
    #         "country": country,
    #         "data": await fetch_logistics(token, {"issuingBayAreaId": id})
    #     }
    #     for country, id in data.items()
    # ]
    # logger.info(len(logistics))

    jp_id = data.get("日本")
    logistics = await fetch_logistics(token, {"issuingBayAreaId": jp_id})
    logger.info(logistics)
    assert "日本黑猫-YAMATO" in [l.get("name") for l in logistics.get("list")]
