/
make_db.py
30 lines (23 loc) · 854 Bytes
/
make_db.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
#populate new db
import sys
from random import choice as ch
from tests.factories import *
from ordonnances.models import Ordonnance
from patients.models import Patient
from unousers.models import UnoUser
# sys.path.append('./unolog') # isort:skip
def populate():
FacPatient.create_batch(3)
FacUnoUser.create_batch(2)
for i in range(20):
FacObservation.create(
owner=ch(UnoUser.objects.all()), patient=ch(Patient.objects.all()))
for i in range(20):
FacOrdonnance.create(
owner=ch(UnoUser.objects.all()), patient=ch(Patient.objects.all()))
for i in range(80):
FacLigneMedicament.create(ordonnance=ch(Ordonnance.objects.all()))
# FacOrdonnance.create_batch(30)
def reset_db():
[i.delete() for i in Patient.objects.all()]
[i.delete() for i in UnoUser.objects.all()[1:]]