from fastapi.testclient import TestClient

from near_fastapi.app import create_app


def test_health() -> None:
    client = TestClient(create_app())
    response = client.get("/health")
    assert response.status_code == 200
    data = response.json()
    assert data["status"] == "ok"
    assert data["service"] == "near-fastapi"


def test_networks() -> None:
    client = TestClient(create_app())
    response = client.get("/v1/networks")
    assert response.status_code == 200
    data = response.json()
    assert len(data) == 2
    assert {x["network"] for x in data} == {"mainnet", "testnet"}


def test_account_validation_error() -> None:
    client = TestClient(create_app())
    response = client.get("/v1/accounts/INVALID!@#")
    assert response.status_code == 422
