mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-01 11:02:56 +02:00
test: lint tests
and tools
aswell (#2296)
* test: lint `tests` and `tools` aswell more linting :) * fix linting issues in tests and tools * fixup! * how is this working?
This commit is contained in:
@ -7,9 +7,9 @@ import time
|
||||
from subprocess import PIPE, Popen, TimeoutExpired
|
||||
from typing import Tuple
|
||||
|
||||
import psycopg2
|
||||
from loguru import logger
|
||||
from sqlalchemy.engine.url import make_url
|
||||
from psycopg2 import connect
|
||||
from psycopg2.errors import InvalidCatalogName
|
||||
|
||||
from lnbits import core
|
||||
from lnbits.db import DB_TYPE, POSTGRES
|
||||
@ -158,24 +158,17 @@ def pay_onchain(address: str, sats: int) -> str:
|
||||
|
||||
def clean_database(settings):
|
||||
if DB_TYPE == POSTGRES:
|
||||
db_url = make_url(settings.lnbits_database_url)
|
||||
|
||||
conn = psycopg2.connect(settings.lnbits_database_url)
|
||||
conn = connect(settings.lnbits_database_url)
|
||||
conn.autocommit = True
|
||||
with conn.cursor() as cur:
|
||||
try:
|
||||
cur.execute("DROP DATABASE lnbits_test")
|
||||
except psycopg2.errors.InvalidCatalogName:
|
||||
except InvalidCatalogName:
|
||||
pass
|
||||
cur.execute("CREATE DATABASE lnbits_test")
|
||||
|
||||
db_url.database = "lnbits_test"
|
||||
settings.lnbits_database_url = str(db_url)
|
||||
|
||||
core.db.__init__("database")
|
||||
|
||||
conn.close()
|
||||
else:
|
||||
# FIXME: do this once mock data is removed from test data folder
|
||||
# TODO: do this once mock data is removed from test data folder
|
||||
# os.remove(settings.lnbits_data_folder + "/database.sqlite3")
|
||||
pass
|
||||
|
Reference in New Issue
Block a user