-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
57 lines (41 loc) · 1.25 KB
/
tasks.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
"""tasks.py"""
import os
from invoke.tasks import task
@task
def dev(ctx):
"""Run the project in development mode."""
print("Running Protaskinate in development mode")
ctx.run("flask run --debug --host=0.0.0.0")
@task
def create_schema(ctx):
"""Create the database schema."""
ctx.run("flask create_schema")
@task
def populate_db(ctx):
"""Populate the database with sample data."""
print("Populating database")
ctx.run("flask populate_db")
@task
def generate_secret_key(ctx):
"""Create a secret key."""
if os.path.exists(".secret_key.env"):
print("File already exists - skipping generation")
else:
secret_key = os.urandom(12).hex()
ctx.run("echo 'SECRET_KEY=" + secret_key + "' > .secret_key.env")
print("Secret key generated")
@task
def lint(ctx):
"""Run pylint on the project."""
print("Linting project")
ctx.run("pylint protaskinate", warn=True)
@task
def test(ctx):
"""Run unit tests"""
print("Running unit tests")
ctx.run("pytest tests/unit")
@task
def coverage_report(ctx):
"""Run unit tests and create a coverage report"""
print("Running unit tests and creating coverage report")
ctx.run("pytest --cov-report xml --cov protaskinate tests/unit")