-
Notifications
You must be signed in to change notification settings - Fork 79
/
test_data.py
executable file
·42 lines (34 loc) · 1.01 KB
/
test_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
import argparse
from OpenOversight.app import create_app
from OpenOversight.app.models.database import db
from OpenOversight.app.utils.constants import KEY_ENV_DEV
from OpenOversight.tests.conftest import add_mockdata
app = create_app(KEY_ENV_DEV)
ctx = app.app_context()
ctx.push()
db.app = app
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--populate",
action="store_true",
help="populate the database with test data",
)
parser.add_argument(
"-c",
"--cleanup",
action="store_true",
help="delete all test data from the database",
)
args = parser.parse_args()
if args.populate:
print("[*] Populating database with test data...")
add_mockdata(db.session)
print("[*] Completed successfully!")
if args.cleanup:
print("[*] Cleaning up database...")
db.drop_all()
db.create_all()
print("[*] Completed successfully!")