-
Notifications
You must be signed in to change notification settings - Fork 3
/
resetdb.py
37 lines (31 loc) · 1.22 KB
/
resetdb.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
from django.core.management import call_command
from django.core.management.base import BaseCommand
from api.models import Role, Utility, User
from api.models.role import Roles
class Command(BaseCommand):
help = "Reset the DB schema, run migrations, and create test data."
def handle(self, *args, **options):
call_command("reset_schema", "--noinput")
call_command("migrate")
# Create test utility located in Raleigh.
test_utility = Utility(pwsid="123456789", name="Azavea Test Utility")
test_utility.save()
# Create test users.
User.objects.create_superuser(
email="a1@azavea.com",
password="password",
has_admin_generated_password=False,
)
User.objects.create_user(
email="v1@azavea.com",
password="password",
has_admin_generated_password=False,
role=Role.objects.get(pk=Roles.VALIDATOR),
)
contributor = User.objects.create_user(
email="c1@azavea.com",
password="password",
has_admin_generated_password=False,
role=Role.objects.get(pk=Roles.CONTRIBUTOR),
)
contributor.utilities.add(test_utility)