-
Notifications
You must be signed in to change notification settings - Fork 5
/
fabfile.py
57 lines (39 loc) · 1.52 KB
/
fabfile.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
"""
Creating standalone Django apps is a PITA because you're not in a project, so
you don't have a settings.py file. I can never remember to define
DJANGO_SETTINGS_MODULE, so I run these commands which get the right env
automatically.
"""
import functools
import os
from fabric.api import local as _local
NAME = os.path.basename(os.path.dirname(__file__))
ROOT = os.path.abspath(os.path.dirname(__file__))
APP_NAME = 'variant'
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_app.settings'
os.environ['PYTHONPATH'] = os.pathsep.join([ROOT, ])
_local = functools.partial(_local, capture=False)
def shell():
"""Start a Django shell with the test settings."""
_local('django-admin.py shell')
def test(test_case=''):
"""Run the test suite."""
_local('django-admin.py test %s' % test_case)
def test_coverage():
_local('coverage run --source=%s --omit=*/migrations/*.py '
'$(which django-admin.py) test' % APP_NAME)
def serve():
"""Start the Django dev server."""
_local('django-admin.py runserver')
def syncdb():
"""Create a database for testing in the shell or server."""
_local('django-admin.py syncdb')
def schema(initial=False):
"""Create a schema migration for any changes."""
if initial:
_local('django-admin.py schemamigration %s --initial' % APP_NAME)
else:
_local('django-admin.py schemamigration %s --auto' % APP_NAME)
def migrate(migration=''):
"""Update a testing database with south."""
_local('django-admin.py migrate %s %s' % (APP_NAME, migration))