-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake.py
31 lines (26 loc) · 1.07 KB
/
fake.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
from random import randint
from .webapp.qa.models import db, User, Role, bcrypt
from .main import Request
from sqlalchemy.exc import IntegrityError
import logging
dict = ['Anxiety disorder', 'Eating disorder', 'Sleep disorder']
desc = ['Anxiety disorder: Anxiety or fear that interferes with normal functioning may be classified as an anxiety disorder.',
'These disorders involve disproportionate concern in matters of food and weight.',
'These conditions are associated with disruption to normal sleep patterns. A common sleep disorder is insomnia, which is described as difficulty falling and/or staying asleep.']
def users(count=len(dict)):
i = 0
while i < count:
r = Request(dict[i])
r.content = desc[i]
r.user_foreignkey = randint(0, 1)
db.session.add(r)
try:
db.session.commit()
i += 1
except IntegrityError:
db.session.rollback()
fake_users = [
{'username': 'user_default', 'role': 'default'},
{'username': 'admin', 'role': 'admin'}
]
fake_roles = ['default', 'admin']