From ed2029533f4da25724b11f40b098acffa4769b8f Mon Sep 17 00:00:00 2001 From: richard-dds Date: Wed, 5 Sep 2018 16:15:59 -0400 Subject: [PATCH 1/2] Fix seed script --- script/seed.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/script/seed.py b/script/seed.py index 03bbbb5c..9b4c64a0 100644 --- a/script/seed.py +++ b/script/seed.py @@ -5,6 +5,7 @@ import sys parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) sys.path.append(parent_dir) +from atst.database import db from atst.app import make_config, make_app from atst.domain.users import Users from atst.domain.requests import Requests @@ -27,9 +28,11 @@ def seed_db(): for user in users: requests = [] for dollar_value in [1, 200, 3000, 40000, 500000, 1000000]: - request = Requests.create( - user, RequestFactory.build_request_body(user, dollar_value) - ) + request = RequestFactory.build(creator=user) + request.latest_revision.dollar_value = dollar_value + db.session.add(request) + db.session.commit() + Requests.submit(request) requests.append(request) From 50d11368afd8f7848d39b4681308c86aade8c36e Mon Sep 17 00:00:00 2001 From: richard-dds Date: Wed, 5 Sep 2018 16:45:53 -0400 Subject: [PATCH 2/2] Divulge script/seed in the README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 18744a33..e6c6f1c3 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,13 @@ For example `/login-dev?username=amanda`. In development mode, there is a `DEV Login` button available on the home page that will automatically log you in as Amanda. +### Seeding the database + +We have a helper script that will seed the database with requests, workspaces and +projects for all of the test users: + +`pipenv run python script/seed.py` + ## Testing Tests require a test database: