[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 11:21:05 +01:00
committed by GitHub
parent 0b3d5bbe0e
commit a97f298586
3 changed files with 18 additions and 17 deletions
+14 -12
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__":