-
Notifications
You must be signed in to change notification settings - Fork 3
/
pavement.py
86 lines (63 loc) · 1.9 KB
/
pavement.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
""" Pavement file for ddionrails project """
import pathlib
import sys
import django
from django.core import management
from django.db.utils import IntegrityError
from paver.easy import consume_args, needs, sh, task
sys.path.append(".")
@task
def docu():
"""Run the docu make script (no delete)."""
sh("cd ../docs; make html")
@task
def full_docu():
"""Completely rebuild the docu."""
sh("cd ../docs; rm -r _build; make html")
@task
def django_setup():
""" Setup django for other tasks """
django.setup()
@task
@needs("django_setup")
def create_admin():
"""Create superuser "admin" with password "test"."""
from django.contrib.auth.models import User
try:
User.objects.create_superuser("admin", "admin@example.com", "test")
except IntegrityError:
# User "admin" already exists
pass
@task
@needs("django_setup")
def reset_migrations():
"""Reset all migrations."""
migration_files = pathlib.Path("ddionrails").glob("*/migrations/0*.py")
for migration_file in migration_files:
migration_file.unlink()
management.call_command("makemigrations")
@task
@needs("django_setup")
def erd():
"""Create an entity relationship diagram """
management.call_command(
"graph_models", all_applications=True, outputfile="local/erd.png"
)
@task
@needs("django_setup")
def migrate():
"""Make migrations and run migrate."""
management.call_command("makemigrations")
management.call_command("migrate")
@task
@needs("django_setup")
@consume_args
def test(args):
""" Test the project without functional tests """
sh(f"DJANGO_SETTINGS_MODULE=config.settings.testing pytest -rf -m 'not functional' {' '.join(args)}")
@task
@needs("django_setup")
def functional_test():
""" Test the project with functional tests """
sh("DJANGO_SETTINGS_MODULE=config.settings.testing pytest -rf -m functional")