Merge pull request #249 from dod-ccpo/fix-seed

Fix seed script
This commit is contained in:
andrewdds 2018-09-06 08:49:28 -04:00 committed by GitHub
commit 033b366ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -104,6 +104,13 @@ For example `/login-dev?username=amanda`.
In development mode, there is a `DEV Login` button available on the home page In development mode, there is a `DEV Login` button available on the home page
that will automatically log you in as Amanda. 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 ## Testing
Tests require a test database: Tests require a test database:

View File

@ -5,6 +5,7 @@ import sys
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(parent_dir) sys.path.append(parent_dir)
from atst.database import db
from atst.app import make_config, make_app from atst.app import make_config, make_app
from atst.domain.users import Users from atst.domain.users import Users
from atst.domain.requests import Requests from atst.domain.requests import Requests
@ -27,9 +28,11 @@ def seed_db():
for user in users: for user in users:
requests = [] requests = []
for dollar_value in [1, 200, 3000, 40000, 500000, 1000000]: for dollar_value in [1, 200, 3000, 40000, 500000, 1000000]:
request = Requests.create( request = RequestFactory.build(creator=user)
user, RequestFactory.build_request_body(user, dollar_value) request.latest_revision.dollar_value = dollar_value
) db.session.add(request)
db.session.commit()
Requests.submit(request) Requests.submit(request)
requests.append(request) requests.append(request)