[fix] Fix missing timezone information

This commit is contained in:
Djuri Baars
2026-02-25 07:53:32 +01:00
committed by dni ⚡
parent 2c61e219b8
commit dbcc920d0a
2 changed files with 29 additions and 3 deletions
+22 -1
View File
@@ -1,4 +1,4 @@
from datetime import date
from datetime import date, timezone
import pytest
@@ -8,6 +8,9 @@ from lnbits.core.crud import (
get_wallet,
get_wallet_for_key,
)
from lnbits.core.crud.payments import get_payment
from lnbits.core.models import CreateInvoice
from lnbits.core.services.payments import create_wallet_invoice
from lnbits.db import POSTGRES
@@ -18,6 +21,24 @@ async def test_date_conversion(db):
assert row and isinstance(row.get("now"), date)
@pytest.mark.anyio
async def test_payment_datetime_fields_have_timezone(app, to_user):
"""Test that Payment datetime fields always have UTC timezone info."""
wallet = await create_wallet(user_id=to_user.id, wallet_name="test_tz_wallet")
invoice_data = CreateInvoice(amount=10, memo="timezone_test", out=False)
invoice = await create_wallet_invoice(wallet.id, invoice_data)
payment = await get_payment(invoice.checking_id)
assert payment is not None
# All datetime fields should have UTC timezone info
assert payment.time.tzinfo == timezone.utc
assert payment.created_at.tzinfo == timezone.utc
assert payment.updated_at.tzinfo == timezone.utc
if payment.expiry:
assert payment.expiry.tzinfo == timezone.utc
# make test to create wallet and delete wallet
@pytest.mark.anyio
async def test_create_wallet_and_delete_wallet(app, to_user):