Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

10.0 KB
Raw Blame
import pytest
from httpx import AsyncClient


@pytest.mark.asyncio
async def test_list_currencies(client: AsyncClient):
    response = await client.get("/api/currencies")
    assert response.status_code == 200
    data = response.json()
    assert isinstance(data, list)
    assert len(data) > 0
    for currency in data:
        assert "code" in currency
        assert "symbol" in currency
        assert "name" in currency
        assert "flag" in currency


@pytest.mark.asyncio
async def test_currencies_include_brl_and_usd(client: AsyncClient):
    response = await client.get("/api/currencies")
    codes = [c["code"] for c in response.json()]
    assert "BRL" in codes
    assert "USD" in codes


@pytest.mark.asyncio
async def test_currencies_include_clp_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    clp = next((currency for currency in data if currency["code"] == "CLP"), None)

    assert clp is not None
    assert clp["symbol"] == "$"
    assert clp["name"] == "Peso Chileno"
    assert clp["flag"] == "πŸ‡¨πŸ‡±"


@pytest.mark.asyncio
async def test_currencies_include_dop_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    dop = next((currency for currency in data if currency["code"] == "DOP"), None)

    assert dop is not None
    assert dop["symbol"] == "RD$"
    assert dop["name"] == "Peso Dominicano"
    assert dop["flag"] == "πŸ‡©πŸ‡΄"


@pytest.mark.asyncio
async def test_currencies_include_uah_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    uah = next((currency for currency in data if currency["code"] == "UAH"), None)

    assert uah is not None
    assert uah["symbol"] == "β‚΄"
    assert uah["name"] == "Ukrainian Hryvnia"
    assert uah["flag"] == "πŸ‡ΊπŸ‡¦"


@pytest.mark.asyncio
async def test_currencies_include_nzd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    nzd = next((currency for currency in data if currency["code"] == "NZD"), None)

    assert nzd is not None
    assert nzd["symbol"] == "NZ$"
    assert nzd["name"] == "New Zealand Dollar"
    assert nzd["flag"] == "πŸ‡³πŸ‡Ώ"


@pytest.mark.asyncio
async def test_currencies_include_vnd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    vnd = next((currency for currency in data if currency["code"] == "VND"), None)

    assert vnd is not None
    assert vnd["symbol"] == "β‚«"
    assert vnd["name"] == "Vietnamese Dong"
    assert vnd["flag"] == "πŸ‡»πŸ‡³"


@pytest.mark.asyncio
async def test_currencies_include_sgd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    sgd = next((currency for currency in data if currency["code"] == "SGD"), None)

    assert sgd is not None
    assert sgd["symbol"] == "S$"
    assert sgd["name"] == "Singapore Dollar"
    assert sgd["flag"] == "πŸ‡ΈπŸ‡¬"


@pytest.mark.asyncio
async def test_currencies_include_azn_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    
    azn = next((currency for currency in data if currency["code"] == "AZN"), None)
    
    assert azn is not None
    assert azn["symbol"] == "β‚Ό"
    assert azn["name"] == "Azerbaijani Manat"
    assert azn["flag"] == "πŸ‡¦πŸ‡Ώ"


@pytest.mark.asyncio
async def test_currencies_include_try_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    turkish_lira = next((currency for currency in data if currency["code"] == "TRY"), None)

    assert turkish_lira is not None
    assert turkish_lira["symbol"] == "β‚Ί"
    assert turkish_lira["name"] == "Turkish Lira"
    assert turkish_lira["flag"] == "πŸ‡ΉπŸ‡·"


@pytest.mark.asyncio
async def test_currencies_include_pkr_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    pkr = next((currency for currency in data if currency["code"] == "PKR"), None)

    assert pkr is not None
    assert pkr["symbol"] == "₨"
    assert pkr["name"] == "Pakistani Rupee"
    assert pkr["flag"] == "πŸ‡΅πŸ‡°"


@pytest.mark.asyncio
async def test_currencies_include_mdl_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    mdl = next((currency for currency in data if currency["code"] == "MDL"), None)

    assert mdl is not None
    assert mdl["symbol"] == "L"
    assert mdl["name"] == "Moldovan Leu"
    assert mdl["flag"] == "πŸ‡²πŸ‡©"
async def test_currencies_include_aed_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    aed = next((currency for currency in data if currency["code"] == "AED"), None)

    assert aed is not None
    assert aed["symbol"] == "Ψ―.Ψ₯"
    assert aed["name"] == "UAE Dirham"
    assert aed["flag"] == "πŸ‡¦πŸ‡ͺ"


@pytest.mark.asyncio
async def test_currencies_include_thb_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    thb = next((currency for currency in data if currency["code"] == "THB"), None)

    assert thb is not None
    assert thb["symbol"] == "ΰΈΏ"
    assert thb["name"] == "Thai Baht"
    assert thb["flag"] == "πŸ‡ΉπŸ‡­"
async def test_currencies_include_egp_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    egp = next((currency for currency in data if currency["code"] == "EGP"), None)

    assert egp is not None
    assert egp["symbol"] == "EΒ£"
    assert egp["name"] == "Egyptian Pound"
    assert egp["flag"] == "πŸ‡ͺπŸ‡¬"
async def test_currencies_include_myr_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    myr = next((currency for currency in data if currency["code"] == "MYR"), None)

    assert myr is not None
    assert myr["symbol"] == "RM"
    assert myr["name"] == "Malaysian Ringgit"
    assert myr["flag"] == "πŸ‡²πŸ‡Ύ"


@pytest.mark.asyncio
async def test_currencies_include_cny_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    cny = next((currency for currency in data if currency["code"] == "CNY"), None)

    assert cny is not None
    assert cny["symbol"] == "Β₯"
    assert cny["name"] == "Chinese Yuan"
    assert cny["flag"] == "πŸ‡¨πŸ‡³"


@pytest.mark.asyncio
async def test_currencies_include_sar_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    sar = next((currency for currency in data if currency["code"] == "SAR"), None)

    assert sar is not None
    assert sar["symbol"] == "Ψ±.Ψ³"
    assert sar["name"] == "Saudi Riyal"
    assert sar["flag"] == "πŸ‡ΈπŸ‡¦"


@pytest.mark.asyncio
async def test_currencies_include_qar_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    qar = next((currency for currency in data if currency["code"] == "QAR"), None)

    assert qar is not None
    assert qar["symbol"] == "Ψ±.Ω‚"
    assert qar["name"] == "Qatari Riyal"
    assert qar["flag"] == "πŸ‡ΆπŸ‡¦"
async def test_currencies_include_jmd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    jmd = next((currency for currency in data if currency["code"] == "JMD"), None)

    assert jmd is not None
    assert jmd["symbol"] == "J$"
    assert jmd["name"] == "Jamaican Dollar"
    assert jmd["flag"] == "πŸ‡―πŸ‡²"


@pytest.mark.asyncio
async def test_currencies_include_rsd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    rsd = next((currency for currency in data if currency["code"] == "RSD"), None)

    assert rsd is not None
    assert rsd["symbol"] == "RSD"
    assert rsd["name"] == "Serbian Dinar"
    assert rsd["flag"] == "πŸ‡·πŸ‡Έ"


@pytest.mark.asyncio
async def test_currencies_include_mkd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    mkd = next((currency for currency in data if currency["code"] == "MKD"), None)

    assert mkd is not None
    assert mkd["symbol"] == "Π΄Π΅Π½"
    assert mkd["name"] == "Macedonian Denar"
    assert mkd["flag"] == "πŸ‡²πŸ‡°"


@pytest.mark.asyncio
async def test_currencies_include_hkd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    hkd = next((currency for currency in data if currency["code"] == "HKD"), None)

    assert hkd is not None
    assert hkd["symbol"] == "HK$"
    assert hkd["name"] == "Hong Kong Dollar"
    assert hkd["flag"] == "πŸ‡­πŸ‡°"


@pytest.mark.asyncio
async def test_currencies_include_twd_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    twd = next((currency for currency in data if currency["code"] == "TWD"), None)

    assert twd is not None
    assert twd["symbol"] == "NT$"
    assert twd["name"] == "New Taiwan Dollar"
    assert twd["flag"] == "πŸ‡ΉπŸ‡Ό"


@pytest.mark.asyncio
async def test_currencies_include_zar_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    zar = next((currency for currency in data if currency["code"] == "ZAR"), None)

    assert zar is not None
    assert zar["symbol"] == "R"
    assert zar["name"] == "South African Rand"
    assert zar["flag"] == "πŸ‡ΏπŸ‡¦"


@pytest.mark.asyncio
async def test_currencies_include_gel_with_metadata(client: AsyncClient):
    response = await client.get("/api/currencies")
    data = response.json()
    gel = next((currency for currency in data if currency["code"] == "GEL"), None)

    assert gel is not None
    assert gel["symbol"] == "β‚Ύ"
    assert gel["name"] == "Georgian Lari"
    assert gel["flag"] == "πŸ‡¬πŸ‡ͺ"