chore: update to latest pytest (#2800)
This commit is contained in:
parent
8ff4962e86
commit
291c69e470
27 changed files with 303 additions and 310 deletions
|
|
@ -1,23 +1,28 @@
|
|||
import pytest_asyncio
|
||||
import pytest
|
||||
|
||||
from .helpers import get_hold_invoice, get_real_invoice
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
@pytest.fixture(scope="session")
|
||||
def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def hold_invoice():
|
||||
invoice = get_hold_invoice(100)
|
||||
yield invoice
|
||||
del invoice
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
@pytest.fixture(scope="function")
|
||||
async def real_invoice():
|
||||
invoice = get_real_invoice(100)
|
||||
yield {"bolt11": invoice["payment_request"]}
|
||||
del invoice
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
@pytest.fixture(scope="function")
|
||||
async def real_amountless_invoice():
|
||||
invoice = get_real_invoice(0)
|
||||
yield invoice["payment_request"]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ async def get_node_balance_sats():
|
|||
return balance.node_balance_msats / 1000
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_real_invoice(
|
||||
client, real_invoice, adminkey_headers_from, inkey_headers_from, from_wallet_ws
|
||||
|
|
@ -60,7 +60,7 @@ async def test_pay_real_invoice(
|
|||
assert prev_balance - balance == 100
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@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()
|
||||
|
|
@ -106,7 +106,7 @@ async def test_create_real_invoice(client, adminkey_headers_from, inkey_headers_
|
|||
await task
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_real_invoice_set_pending_and_check_state(
|
||||
client, real_invoice, adminkey_headers_from, inkey_headers_from
|
||||
|
|
@ -145,7 +145,7 @@ async def test_pay_real_invoice_set_pending_and_check_state(
|
|||
assert payment.success
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_hold_invoice_check_pending(
|
||||
client, hold_invoice, adminkey_headers_from
|
||||
|
|
@ -174,7 +174,7 @@ async def test_pay_hold_invoice_check_pending(
|
|||
assert payment_db_after_settlement
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_hold_invoice_check_pending_and_fail(
|
||||
client, hold_invoice, adminkey_headers_from
|
||||
|
|
@ -209,7 +209,7 @@ async def test_pay_hold_invoice_check_pending_and_fail(
|
|||
assert payment_db_after_settlement.failed is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_hold_invoice_check_pending_and_fail_cancel_payment_task_in_meantime(
|
||||
client, hold_invoice, adminkey_headers_from
|
||||
|
|
@ -248,7 +248,7 @@ async def test_pay_hold_invoice_check_pending_and_fail_cancel_payment_task_in_me
|
|||
assert status.failed
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_receive_real_invoice_set_pending_and_check_state(
|
||||
client, adminkey_headers_from, inkey_headers_from
|
||||
|
|
@ -308,7 +308,7 @@ async def test_receive_real_invoice_set_pending_and_check_state(
|
|||
await task
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_check_fee_reserve(client, adminkey_headers_from):
|
||||
# if regtest, create a real invoice, otherwise create an internal invoice
|
||||
# call /api/v1/payments/fee-reserve?invoice=... with it and check if the fee reserve
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from lnbits.wallets.base import PaymentStatus
|
|||
description = "test create invoice"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_create_invoice(from_wallet):
|
||||
payment = await create_invoice(
|
||||
wallet_id=from_wallet.id,
|
||||
|
|
@ -28,7 +28,7 @@ async def test_create_invoice(from_wallet):
|
|||
assert status.pending
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_create_internal_invoice(from_wallet):
|
||||
payment = await create_invoice(
|
||||
wallet_id=from_wallet.id, amount=1000, memo=description, internal=True
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from lnbits.exceptions import PaymentError
|
|||
description = "test pay invoice"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_services_pay_invoice(to_wallet, real_invoice):
|
||||
payment = await pay_invoice(
|
||||
wallet_id=to_wallet.id,
|
||||
|
|
@ -21,7 +21,7 @@ async def test_services_pay_invoice(to_wallet, real_invoice):
|
|||
assert payment.memo == description
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_services_pay_invoice_0_amount_invoice(
|
||||
to_wallet, real_amountless_invoice
|
||||
):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from pydantic import parse_obj_as
|
|||
|
||||
from lnbits import bolt11
|
||||
from lnbits.nodes.base import ChannelPoint, ChannelState, NodeChannel
|
||||
from tests.conftest import pytest_asyncio
|
||||
|
||||
from ..helpers import (
|
||||
funding_source,
|
||||
|
|
@ -24,7 +23,7 @@ pytestmark = pytest.mark.skipif(
|
|||
)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture()
|
||||
@pytest.fixture()
|
||||
async def node_client(client, from_super_user, settings):
|
||||
settings.lnbits_node_ui = True
|
||||
settings.lnbits_public_node_ui = False
|
||||
|
|
@ -36,39 +35,39 @@ async def node_client(client, from_super_user, settings):
|
|||
settings.lnbits_node_ui = False
|
||||
|
||||
|
||||
@pytest_asyncio.fixture()
|
||||
@pytest.fixture()
|
||||
async def public_node_client(node_client, settings):
|
||||
settings.lnbits_public_node_ui = True
|
||||
yield node_client
|
||||
settings.lnbits_public_node_ui = False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_node_info_not_found(client, from_super_user, settings):
|
||||
settings.lnbits_node_ui = False
|
||||
response = await client.get("/node/api/v1/info", params={"usr": from_super_user.id})
|
||||
assert response.status_code == HTTPStatus.SERVICE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_public_node_info_not_found(node_client):
|
||||
response = await node_client.get("/node/public/api/v1/info")
|
||||
assert response.status_code == HTTPStatus.SERVICE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_public_node_info(public_node_client):
|
||||
response = await public_node_client.get("/node/public/api/v1/info")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_node_info(node_client):
|
||||
response = await node_client.get("/node/api/v1/info")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_node_invoices(inkey_headers_from, node_client):
|
||||
data = await get_random_invoice_data()
|
||||
response = await node_client.post(
|
||||
|
|
@ -83,7 +82,7 @@ async def test_node_invoices(inkey_headers_from, node_client):
|
|||
assert invoices[0]["payment_hash"] == invoice["payment_hash"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_node_payments(node_client, real_invoice, adminkey_headers_from):
|
||||
response = await node_client.post(
|
||||
"/api/v1/payments", json=real_invoice, headers=adminkey_headers_from
|
||||
|
|
@ -100,7 +99,7 @@ async def test_node_payments(node_client, real_invoice, adminkey_headers_from):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_channel_management(node_client):
|
||||
async def get_channels():
|
||||
response = await node_client.get("/node/api/v1/channels")
|
||||
|
|
@ -147,7 +146,7 @@ async def test_channel_management(node_client):
|
|||
mine_blocks(5)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_peer_management(node_client):
|
||||
connect_uri = get_unconnected_node_uri()
|
||||
peer_id = connect_uri.split("@")[0]
|
||||
|
|
@ -171,7 +170,7 @@ async def test_peer_management(node_client):
|
|||
assert response.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.anyio
|
||||
async def test_connect_invalid_uri(node_client):
|
||||
response = await node_client.post("/node/api/v1/peers", json={"uri": "invalid"})
|
||||
assert response.status_code == 400
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue