diff --git a/poetry.lock b/poetry.lock index 27305b0c..f202d323 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1060,22 +1060,6 @@ docs = ["alabaster (==0.7.12)", "autodocsumm (==0.2.9)", "sphinx (==5.3.0)", "sp lint = ["flake8 (==5.0.4)", "flake8-bugbear (==22.10.25)", "mypy (==0.990)", "pre-commit (>=2.4,<3.0)"] tests = ["pytest", "pytz", "simplejson"] -[[package]] -name = "mock" -version = "4.0.3" -description = "Rolling backport of unittest.mock for all Pythons" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mock-4.0.3-py3-none-any.whl", hash = "sha256:122fcb64ee37cfad5b3f48d7a7d51875d7031aaf3d8be7c42e2bee25044eee62"}, - {file = "mock-4.0.3.tar.gz", hash = "sha256:7d3fbbde18228f4ff2f1f119a45cdffa458b4c0dee32eb4d2bb2f82554bac7bc"}, -] - -[package.extras] -build = ["blurb", "twine", "wheel"] -docs = ["sphinx"] -test = ["pytest (<5.4)", "pytest-cov"] - [[package]] name = "mypy" version = "1.5.1" @@ -2288,4 +2272,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.10 | ^3.9" -content-hash = "1c9503faaa16edf4068424ef3e48b2e354fb9414c8743d9bf55b18efbe0f2ce4" +content-hash = "3b1b73b1df182fae17e692b1ebd6d35a8791ca62df3ece145b05ae7f4465ae16" diff --git a/pyproject.toml b/pyproject.toml index f454da7f..7a9250c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ slowapi = "^0.1.7" [tool.poetry.group.dev.dependencies] pytest = "^7.1.2" -mock = "^4.0.3" black = "^23.7.0" pytest-asyncio = "^0.19.0" pytest-cov = "^4.1.0" diff --git a/tests/core/views/__init__.py b/tests/core/views/__init__.py index 0b5e2db1..e69de29b 100644 --- a/tests/core/views/__init__.py +++ b/tests/core/views/__init__.py @@ -1 +0,0 @@ -from tests.mocks import WALLET diff --git a/tests/mocks.py b/tests/mocks.py deleted file mode 100644 index 8d1f04e0..00000000 --- a/tests/mocks.py +++ /dev/null @@ -1,77 +0,0 @@ -from mock import AsyncMock - -from lnbits import bolt11 -from lnbits.wallets.base import PaymentResponse, PaymentStatus, StatusResponse -from lnbits.wallets.fake import FakeWallet - -from .helpers import WALLET, get_random_string, is_fake - - -# generates an invoice with FakeWallet -async def generate_mock_invoice(**x): - invoice = await FakeWallet.create_invoice( - FakeWallet(), amount=10, memo=f"mock invoice {get_random_string()}" - ) - return invoice - - -if is_fake: - WALLET.status = AsyncMock( - return_value=StatusResponse( - "", # no error - 1000000, # msats - ) - ) - -# Note: if this line is uncommented, invoices will always be generated by FakeWallet -# WALLET.create_invoice = generate_mock_invoice - -# NOTE: This mock fails since it yields the same invoice multiple -# times which makes the db throw an error due to uniqueness contraints -# on the checking ID - -# # primitive event loop for generate_mock_invoice() -# def drive(c): -# while True: -# try: -# c.send(None) -# except StopIteration as e: -# return e.value - -# # finally we await it -# invoice = drive(generate_mock_invoice()) - -# WALLET.create_invoice = AsyncMock( -# return_value=InvoiceResponse( -# True, # ok -# invoice.checking_id, # checking_id (i.e. payment_hash) -# invoice.payment_request, # payment_request -# "", # no error -# ) -# ) - - -if is_fake: - - def pay_invoice_side_effect( - payment_request: str, fee_limit_msat: int - ) -> PaymentResponse: - invoice = bolt11.decode(payment_request) - return PaymentResponse( - True, # ok - invoice.payment_hash, # checking_id (i.e. payment_hash) - 0, # fee_msat - "", # no error - ) - - WALLET.pay_invoice = AsyncMock(side_effect=pay_invoice_side_effect) - WALLET.get_invoice_status = AsyncMock( - return_value=PaymentStatus( - True, # paid - ) - ) - WALLET.get_payment_status = AsyncMock( - return_value=PaymentStatus( - True, # paid - ) - )