forked from italomaia/flask-empty
-
Notifications
You must be signed in to change notification settings - Fork 2
/
commands.py
47 lines (32 loc) · 1.02 KB
/
commands.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
# -*- coding:utf-8 -*-
from flask.ext.script import Command, Option, prompt_bool
import os
import config
class CreateDB(Command):
"Creates sqlalchemy database"
def run(self):
from database import create_all
create_all()
class DropDB(Command):
"Drops sqlalchemy database"
def run(self):
from database import drop_all
drop_all()
class Test(Command):
"Run tests."
start_discovery_dir = "tests"
def get_options(self):
return [
Option('--start_discover', '-s', dest='start_discovery',
help='Pattern to search for features',
default=self.start_discovery_dir),
]
def run(self, start_discovery):
import unittest
if os.path.exists(start_discovery):
argv = [config.project_name, "discover"]
argv += ["-s", start_discovery]
unittest.main(argv=argv)
else:
print("Directory '%s' was not found in project root." % \
start_discovery)