From e3b629fe001c75caca0f430ee5137305e4386af7 Mon Sep 17 00:00:00 2001 From: MR Lemon Date: Wed, 13 May 2020 16:08:00 +0100 Subject: refactored populate script into a new core app - better positioned for use in tests --- ctrack/core/management/__init__.py | 0 ctrack/core/management/commands/__init__.py | 0 ctrack/core/management/commands/populate_db.py | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 ctrack/core/management/__init__.py create mode 100644 ctrack/core/management/commands/__init__.py create mode 100644 ctrack/core/management/commands/populate_db.py (limited to 'ctrack/core/management') diff --git a/ctrack/core/management/__init__.py b/ctrack/core/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ctrack/core/management/commands/__init__.py b/ctrack/core/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ctrack/core/management/commands/populate_db.py b/ctrack/core/management/commands/populate_db.py new file mode 100644 index 0000000..5b8f541 --- /dev/null +++ b/ctrack/core/management/commands/populate_db.py @@ -0,0 +1,24 @@ + +from django.core.management import BaseCommand +from django.core.management import CommandParser +from ctrack.core.utils import populate_db + + +class Command(BaseCommand): + help = """ + Creates a large test fixture. + """ + + def add_arguments(self, parser: CommandParser) -> None: + parser.add_argument("number", nargs=1, type=int) + + def handle(self, *args, **options): + number = options["number"][0] + populate_db(number) + + # TODO - adapt this so that it records more than just Persons created + self.stdout.write( + self.style.SUCCESS( + f"Created {number} Person object[s]! Go forth and multiply." + ) + ) -- cgit v1.2.3