diff --git a/Makefile b/Makefile index b1e2b4f6..dca550d0 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lnbits/commands.py b/lnbits/commands.py index f8f396dc..3dcab0f2 100644 --- a/lnbits/commands.py +++ b/lnbits/commands.py @@ -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__": diff --git a/tests/data/mock_data.zip b/tests/data/mock_data.zip deleted file mode 100644 index e8039b2f..00000000 Binary files a/tests/data/mock_data.zip and /dev/null differ