Open-source personal finance manager. Self-hosted, privacy-first.
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"] == "π¬πͺ"