Skip to content

Commit

Permalink
Sorting out errors for postgres and adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-s authored and bfirsh committed Nov 17, 2018
1 parent 0f3d612 commit 4ea3a34
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions api/tests/commands/test_data_generation.py
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 1 addition & 1 deletion core/factory_apps/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion core/factory_apps/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions core/management/commands/generate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions docs/how-to-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down

0 comments on commit 4ea3a34

Please sign in to comment.