-
Notifications
You must be signed in to change notification settings - Fork 1
/
runburgerzilla.py
37 lines (29 loc) · 921 Bytes
/
runburgerzilla.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
import os
from dotenv import load_dotenv
import click
# to get the environment variables
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
from flask_migrate import Migrate
from app import create_app,db
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)
@app.cli.command()
@click.argument('test_names', nargs=-1)
def test(test_names):
"""Run unit test """
import unittest
if test_names:
"""
flask test
--test_names=test_auth_restaurant.py
--test_names=test_auth_customer.py
"""
tests = unittest.TestLoader().loadTestsFromNames(test_names)
else:
tests = unittest.TestLoader().discover('tests',pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1