Release v4928.1.4.2 stable
This commit is contained in:
51
scripts/test_jasmin_connection.py
Executable file
51
scripts/test_jasmin_connection.py
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Teste não destrutivo da integração Jasmin.
|
||||
|
||||
Não cria clientes/documentos. Valida OAuth, versão, OData de clientes,
|
||||
produtos, orçamentos e faturas.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
os.chdir(PROJECT_ROOT)
|
||||
|
||||
__test__ = False
|
||||
|
||||
|
||||
def show(title: str, value, limit: int = 2500) -> None:
|
||||
print(f"\n=== {title} ===")
|
||||
try:
|
||||
text = json.dumps(value, indent=2, ensure_ascii=False, default=str)
|
||||
except Exception:
|
||||
text = str(value)
|
||||
print(text[:limit])
|
||||
|
||||
|
||||
async def main() -> int:
|
||||
from app.jasmin_client import JasminClient, JasminError
|
||||
|
||||
client = JasminClient()
|
||||
try:
|
||||
token = await client.get_token()
|
||||
print(f"OAuth OK: token_length={len(token)}")
|
||||
show("Versões", await client.get_versions())
|
||||
show("Clientes OData", await client.list_customers_odata(top=5))
|
||||
show("Produtos OData", await client.list_sales_items(top=10))
|
||||
show("Últimos orçamentos", await client.list_quotations(top=5))
|
||||
show("Últimas faturas", await client.list_invoices(top=5))
|
||||
except JasminError as exc:
|
||||
print(f"ERRO Jasmin: {exc}")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(asyncio.run(main()))
|
||||
Reference in New Issue
Block a user