forked from LS80/python-code-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
47 lines (27 loc) · 1.09 KB
/
fabfile.py
File metadata and controls
47 lines (27 loc) · 1.09 KB
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
import os
from fabric.api import local
def run_manage(command, capture=False):
return local('/home/ubuntu/.virtualenvs/code-test/bin/python /vagrant/testsite/manage.py %s' % command, capture=capture)
def web():
run_manage('runserver 0.0.0.0:8888')
def migrate():
run_manage('migrate')
def make_migrations():
run_manage('makemigrations')
def requirements():
local('/home/ubuntu/.virtualenvs/code-test/bin/pip install -r requirements.txt ')
def _save_fixture(app, fixture):
directory = './testsite/{}/fixtures/'.format(app)
if not os.path.exists(directory):
os.makedirs(directory)
with open('{}initial_data.json'.format(directory), 'w') as f:
f.writelines(fixture)
def _make_fixture(app):
fixtures = run_manage('dumpdata {} --indent=4'.format(app), capture=True)
_save_fixture(app, fixtures)
def create_fixtures():
_make_fixture('reactions')
_make_fixture('episodes')
def load_fixtures():
run_manage('loaddata ./testsite/reactions/fixtures/initial_data.json')
run_manage('loaddata ./testsite/episodes/fixtures/initial_data.json')