[REFACTOR] cleanup views/api.py (#1865)
pull out models line lengths change models for tests
This commit is contained in:
parent
905afc1f5c
commit
59acd3a2ef
5 changed files with 98 additions and 72 deletions
|
|
@ -8,8 +8,9 @@ from httpx import AsyncClient
|
|||
from lnbits.app import create_app
|
||||
from lnbits.commands import migrate_databases
|
||||
from lnbits.core.crud import create_account, create_wallet
|
||||
from lnbits.core.models import CreateInvoice
|
||||
from lnbits.core.services import update_wallet_balance
|
||||
from lnbits.core.views.api import CreateInvoiceData, api_payments_create_invoice
|
||||
from lnbits.core.views.api import api_payments_create_invoice
|
||||
from lnbits.db import Database
|
||||
from lnbits.settings import settings
|
||||
from tests.helpers import get_hold_invoice, get_random_invoice_data, get_real_invoice
|
||||
|
|
@ -142,7 +143,7 @@ async def adminkey_headers_to(to_wallet):
|
|||
@pytest_asyncio.fixture(scope="session")
|
||||
async def invoice(to_wallet):
|
||||
data = await get_random_invoice_data()
|
||||
invoiceData = CreateInvoiceData(**data)
|
||||
invoiceData = CreateInvoice(**data)
|
||||
invoice = await api_payments_create_invoice(invoiceData, to_wallet)
|
||||
yield invoice
|
||||
del invoice
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from lnbits.core.views.admin_api import api_auditor
|
|||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.db import DB_TYPE, SQLITE
|
||||
from lnbits.wallets import get_wallet_class
|
||||
from tests.conftest import CreateInvoiceData, api_payments_create_invoice
|
||||
from tests.conftest import CreateInvoice, api_payments_create_invoice
|
||||
|
||||
from ...helpers import (
|
||||
cancel_invoice,
|
||||
|
|
@ -219,9 +219,9 @@ async def test_get_payments(client, from_wallet, adminkey_headers_from):
|
|||
ts = time()
|
||||
|
||||
fake_data = [
|
||||
CreateInvoiceData(amount=10, memo="aaaa"),
|
||||
CreateInvoiceData(amount=100, memo="bbbb"),
|
||||
CreateInvoiceData(amount=1000, memo="aabb"),
|
||||
CreateInvoice(amount=10, memo="aaaa"),
|
||||
CreateInvoice(amount=100, memo="bbbb"),
|
||||
CreateInvoice(amount=1000, memo="aabb"),
|
||||
]
|
||||
|
||||
for invoice in fake_data:
|
||||
|
|
@ -384,7 +384,7 @@ async def test_pay_real_invoice(
|
|||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_create_real_invoice(client, adminkey_headers_from, inkey_headers_from):
|
||||
prev_balance = await get_node_balance_sats()
|
||||
create_invoice = CreateInvoiceData(out=False, amount=1000, memo="test")
|
||||
create_invoice = CreateInvoice(out=False, amount=1000, memo="test")
|
||||
response = await client.post(
|
||||
"/api/v1/payments",
|
||||
json=create_invoice.dict(),
|
||||
|
|
@ -604,7 +604,7 @@ async def test_receive_real_invoice_set_pending_and_check_state(
|
|||
5. We recheck the state of the invoice with the backend
|
||||
6. We verify that the invoice is now marked as paid in the database
|
||||
"""
|
||||
create_invoice = CreateInvoiceData(out=False, amount=1000, memo="test")
|
||||
create_invoice = CreateInvoice(out=False, amount=1000, memo="test")
|
||||
response = await client.post(
|
||||
"/api/v1/payments",
|
||||
json=create_invoice.dict(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue