async postgres

add timestamp conversation

pending fixed now

statement

repair conv

remove cleandbsetting
This commit is contained in:
dni ⚡
2024-09-05 12:38:50 +02:00
parent 08ea83c28e
commit 835f56cee6
10 changed files with 156 additions and 102 deletions
-2
View File
@@ -25,7 +25,6 @@ from lnbits.core.views.payment_api import api_payments_create_invoice
from lnbits.db import DB_TYPE, SQLITE, Database
from lnbits.settings import settings
from tests.helpers import (
clean_database,
get_random_invoice_data,
)
@@ -47,7 +46,6 @@ def event_loop():
# use session scope to run once before and once after all tests
@pytest_asyncio.fixture(scope="session")
async def app():
clean_database(settings)
app = create_app()
async with LifespanManager(app) as manager:
settings.first_install = False
+1 -23
View File
@@ -2,11 +2,7 @@ import random
import string
from typing import Optional
from psycopg2 import connect
from psycopg2.errors import InvalidCatalogName
from lnbits import core
from lnbits.db import DB_TYPE, POSTGRES, FromRowModel
from lnbits.db import FromRowModel
from lnbits.wallets import get_funding_source, set_funding_source
@@ -35,21 +31,3 @@ set_funding_source()
funding_source = get_funding_source()
is_fake: bool = funding_source.__class__.__name__ == "FakeWallet"
is_regtest: bool = not is_fake
def clean_database(settings):
if DB_TYPE == POSTGRES:
conn = connect(settings.lnbits_database_url)
conn.autocommit = True
with conn.cursor() as cur:
try:
cur.execute("DROP DATABASE lnbits_test")
except InvalidCatalogName:
pass
cur.execute("CREATE DATABASE lnbits_test")
core.db.__init__("database")
conn.close()
else:
# TODO: do this once mock data is removed from test data folder
# os.remove(settings.lnbits_data_folder + "/database.sqlite3")
pass