mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
6dd9dcb5d4
- Refactor `get_wallet()` to return `ton_balance` and `usdt_balance` in `WalletInfo`. - Update transaction processing to validate balances for both TON and USDT payment methods. - Introduce `parse_required_payment_amount` utility to extract payment amounts from responses. - Modify tests to cover new balance checks and payment method handling. - Upgrade GitHub Actions artifact upload action to v7. - Enhance documentation and examples to reflect changes in wallet balance handling.
22 lines
795 B
Python
22 lines
795 B
Python
"""Unit tests for init payment amount parsing."""
|
|
|
|
from pyfragment.utils.html import parse_required_payment_amount
|
|
|
|
|
|
def test_parse_required_payment_amount_ton_uses_amount() -> None:
|
|
init_response = {"amount": "0.326"}
|
|
assert parse_required_payment_amount(init_response, "ton") == 0.326
|
|
|
|
|
|
def test_parse_required_payment_amount_usdt_uses_amount() -> None:
|
|
init_response = {
|
|
"amount": "0.00075",
|
|
"content": '<span class="icon-before icon-usd">0.75</span>',
|
|
}
|
|
assert parse_required_payment_amount(init_response, "usdt_ton") == 0.00075
|
|
|
|
|
|
def test_parse_required_payment_amount_usdt_falls_back_to_amount() -> None:
|
|
init_response = {"amount": "1.25", "content": "<p>no usd icon</p>"}
|
|
assert parse_required_payment_amount(init_response, "usdt_ton") == 1.25
|