diff --git a/api/tests/commands/test_data_generation.py b/api/tests/commands/test_data_generation.py new file mode 100644 index 00000000..c3e893a1 --- /dev/null +++ b/api/tests/commands/test_data_generation.py @@ -0,0 +1,8 @@ +from django.test import TransactionTestCase +from django.core.management import call_command + + +class DataGenerationTest(TransactionTestCase): + + def test_run_data_generation(self): + call_command('generate_test_data') diff --git a/core/factory_apps/events.py b/core/factory_apps/events.py index 22879203..00a043b1 100644 --- a/core/factory_apps/events.py +++ b/core/factory_apps/events.py @@ -57,7 +57,7 @@ class Meta: organizer_notes = factory.Faker('paragraph') - limit = factory.Faker('random_digit_or_empty') + limit = factory.Faker('random_digit') visibility = Event.PUBLIC status = Event.PENDING diff --git a/core/factory_apps/location.py b/core/factory_apps/location.py index a713228b..bfa2322b 100644 --- a/core/factory_apps/location.py +++ b/core/factory_apps/location.py @@ -107,7 +107,7 @@ class Meta: model = LocationMenu location = factory.SubFactory(LocationFactory) - name = factory.Faker('text') + name = factory.Faker('text', max_nb_chars=15) class FlatpageFactory(factory.DjangoModelFactory): diff --git a/core/management/commands/generate_test_data.py b/core/management/commands/generate_test_data.py index 1cefdeb7..559fedfd 100644 --- a/core/management/commands/generate_test_data.py +++ b/core/management/commands/generate_test_data.py @@ -25,6 +25,8 @@ def handle(self, *args, **options): with connection.cursor() as cursor: statements = flush_db.split('\n') for statement in statements: + if not statement: + continue cursor.execute(statement) call_command('migrate') diff --git a/docs/how-to-run.md b/docs/how-to-run.md index c28c5edd..f2f34592 100644 --- a/docs/how-to-run.md +++ b/docs/how-to-run.md @@ -70,11 +70,12 @@ create your own local_settings.py file from local_settings.example.py. inside th - browse through settings.py. make note of the location of the media directory and media_url, and any other settings of interest. -## initialisation +## Initialisation go back into the top level repository directory and do the following: -- `./manage.py migrate` will initialise the database on first run +- `./manage.py migrate` will initialise the database on first run. In the next step you want to get some initial data into the database. +- `./manage.py generate_test_data`. This will populate the database with some randomized initial data. ## Run!