[TEST] use test data as mockdata (#1929)

* add db group to cli

* delete mock_data.zip

* generate migration data through tests
This commit is contained in:
jackstar12 2023-09-12 12:21:05 +02:00 committed by GitHub
parent 0b3d5bbe0e
commit a97f298586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 17 deletions

View File

@ -48,18 +48,17 @@ test-real-wallet:
poetry run pytest
test-migration:
rm -rf ./migration-data
mkdir -p ./migration-data
unzip tests/data/mock_data.zip -d ./migration-data
LNBITS_ADMIN_UI=True \
make test
HOST=0.0.0.0 \
PORT=5002 \
LNBITS_DATA_FOLDER="./migration-data" \
LNBITS_DATA_FOLDER="./tests/data" \
timeout 5s poetry run lnbits --host 0.0.0.0 --port 5002 || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
HOST=0.0.0.0 \
PORT=5002 \
LNBITS_DATABASE_URL="postgres://lnbits:lnbits@localhost:5432/migration" \
timeout 5s poetry run lnbits --host 0.0.0.0 --port 5002 || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
LNBITS_DATA_FOLDER="./migration-data" \
LNBITS_DATA_FOLDER="./tests/data" \
LNBITS_DATABASE_URL="postgres://lnbits:lnbits@localhost:5432/migration" \
poetry run python tools/conv.py

View File

@ -15,31 +15,38 @@ from .extension_manager import get_valid_extensions
@click.group()
def command_group():
def lnbits_cli():
"""
Python CLI for LNbits
"""
@lnbits_cli.group()
def db():
"""
Database related commands
"""
def get_super_user() -> str:
"""Get the superuser"""
with open(Path(settings.lnbits_data_folder) / ".super_user", "r") as file:
return file.readline()
@click.command("superuser")
@lnbits_cli.command("superuser")
def superuser():
"""Prints the superuser"""
click.echo(get_super_user())
@click.command("superuser-url")
@lnbits_cli.command("superuser-url")
def superuser_url():
"""Prints the superuser"""
click.echo(f"http://{settings.host}:{settings.port}/wallet?usr={get_super_user()}")
@click.command("delete-settings")
@lnbits_cli.command("delete-settings")
def delete_settings():
"""Deletes the settings"""
@ -51,7 +58,7 @@ def delete_settings():
loop.run_until_complete(wrap())
@click.command("database-migrate")
@db.command("migrate")
def database_migrate():
"""Migrate databases"""
loop = asyncio.get_event_loop()
@ -91,7 +98,7 @@ async def migrate_databases():
logger.info("✔️ All migrations done.")
@click.command("database-versions")
@db.command("versions")
def database_versions():
"""Show current database versions"""
loop = asyncio.get_event_loop()
@ -112,12 +119,7 @@ async def load_disabled_extension_list() -> None:
def main():
"""main function"""
command_group.add_command(superuser)
command_group.add_command(superuser_url)
command_group.add_command(delete_settings)
command_group.add_command(database_migrate)
command_group.add_command(database_versions)
command_group()
lnbits_cli()
if __name__ == "__main__":

Binary file not shown.