-
Notifications
You must be signed in to change notification settings - Fork 2
/
fabfile.py
48 lines (32 loc) · 1.02 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
from fabric.decorators import task
from fabric.operations import local
from test.features.driver.server_driver import ServerDriver
@task(default=True)
def default():
test()
@task
def setup():
install_requirements()
@task
def install_requirements():
local('pip install -r requirements.txt --use-mirrors')
local('pip install -r requirements-test.txt --use-mirrors')
@task
def unit():
local("nosetests -a '!needs_server'")
@task
def test():
with YoseServer(port=8080):
local("nosetests --tc=server_url:'http://localhost:8080'")
@task
def run_server():
local("python -c 'import yose; yose.app.run(port=8080)'")
class YoseServer():
def __init__(self, port=8080):
self.port = port
self.server = ServerDriver(name='Yose', port=self.port)
def __enter__(self):
self.server.start(cmd=['gunicorn', 'yose:app', '-w', '1', '-b', '0.0.0.0:{0}'.format(self.port)])
return self.server
def __exit__(self, exc_type, exc_val, exc_tb):
self.server.shutdown()