mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-19 20:14:59 +02:00
[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:
9
Makefile
9
Makefile
@@ -48,18 +48,17 @@ test-real-wallet:
|
|||||||
poetry run pytest
|
poetry run pytest
|
||||||
|
|
||||||
test-migration:
|
test-migration:
|
||||||
rm -rf ./migration-data
|
LNBITS_ADMIN_UI=True \
|
||||||
mkdir -p ./migration-data
|
make test
|
||||||
unzip tests/data/mock_data.zip -d ./migration-data
|
|
||||||
HOST=0.0.0.0 \
|
HOST=0.0.0.0 \
|
||||||
PORT=5002 \
|
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
|
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 \
|
HOST=0.0.0.0 \
|
||||||
PORT=5002 \
|
PORT=5002 \
|
||||||
LNBITS_DATABASE_URL="postgres://lnbits:lnbits@localhost:5432/migration" \
|
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
|
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" \
|
LNBITS_DATABASE_URL="postgres://lnbits:lnbits@localhost:5432/migration" \
|
||||||
poetry run python tools/conv.py
|
poetry run python tools/conv.py
|
||||||
|
|
||||||
|
@@ -15,31 +15,38 @@ from .extension_manager import get_valid_extensions
|
|||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def command_group():
|
def lnbits_cli():
|
||||||
"""
|
"""
|
||||||
Python CLI for LNbits
|
Python CLI for LNbits
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@lnbits_cli.group()
|
||||||
|
def db():
|
||||||
|
"""
|
||||||
|
Database related commands
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def get_super_user() -> str:
|
def get_super_user() -> str:
|
||||||
"""Get the superuser"""
|
"""Get the superuser"""
|
||||||
with open(Path(settings.lnbits_data_folder) / ".super_user", "r") as file:
|
with open(Path(settings.lnbits_data_folder) / ".super_user", "r") as file:
|
||||||
return file.readline()
|
return file.readline()
|
||||||
|
|
||||||
|
|
||||||
@click.command("superuser")
|
@lnbits_cli.command("superuser")
|
||||||
def superuser():
|
def superuser():
|
||||||
"""Prints the superuser"""
|
"""Prints the superuser"""
|
||||||
click.echo(get_super_user())
|
click.echo(get_super_user())
|
||||||
|
|
||||||
|
|
||||||
@click.command("superuser-url")
|
@lnbits_cli.command("superuser-url")
|
||||||
def superuser_url():
|
def superuser_url():
|
||||||
"""Prints the superuser"""
|
"""Prints the superuser"""
|
||||||
click.echo(f"http://{settings.host}:{settings.port}/wallet?usr={get_super_user()}")
|
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():
|
def delete_settings():
|
||||||
"""Deletes the settings"""
|
"""Deletes the settings"""
|
||||||
|
|
||||||
@@ -51,7 +58,7 @@ def delete_settings():
|
|||||||
loop.run_until_complete(wrap())
|
loop.run_until_complete(wrap())
|
||||||
|
|
||||||
|
|
||||||
@click.command("database-migrate")
|
@db.command("migrate")
|
||||||
def database_migrate():
|
def database_migrate():
|
||||||
"""Migrate databases"""
|
"""Migrate databases"""
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
@@ -91,7 +98,7 @@ async def migrate_databases():
|
|||||||
logger.info("✔️ All migrations done.")
|
logger.info("✔️ All migrations done.")
|
||||||
|
|
||||||
|
|
||||||
@click.command("database-versions")
|
@db.command("versions")
|
||||||
def database_versions():
|
def database_versions():
|
||||||
"""Show current database versions"""
|
"""Show current database versions"""
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
@@ -112,12 +119,7 @@ async def load_disabled_extension_list() -> None:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""main function"""
|
"""main function"""
|
||||||
command_group.add_command(superuser)
|
lnbits_cli()
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user