Commit b2e61d5c by Gabriel Falcao

the harvest command now takes a --port argument. closes #214

parent 5e4e9df4
......@@ -25,7 +25,7 @@ from django.test.utils import teardown_test_environment
from lettuce import Runner
from lettuce import registry
from lettuce.django import server
from lettuce.django.server import Server
from lettuce.django import harvest_lettuces
from lettuce.django.server import LettuceServerException
......@@ -49,6 +49,9 @@ class Command(BaseCommand):
make_option('-S', '--no-server', action='store_true', dest='no_server', default=False,
help="will not run django's builtin HTTP server"),
make_option('-P', '--port', type='int', dest='port',
help="the port in which the HTTP server will run at"),
make_option('-d', '--debug-mode', action='store_true', dest='debug', default=False,
help="when put together with builtin HTTP server, forces django to run with settings.DEBUG=True"),
......@@ -98,6 +101,8 @@ class Command(BaseCommand):
apps_to_avoid = tuple(options.get('avoid_apps', '').split(","))
run_server = not options.get('no_server', False)
tags = options.get('tags', None)
server = Server(port=options['port'])
if tags:
print "DEBUG", options
......
......@@ -7,20 +7,8 @@ from nose.tools import assert_equals
@before.harvest
def before_harvest(variables):
assert_equals(variables.keys(), [
'paths',
'args',
'failed',
'run_server',
'verbosity',
'tags',
'self',
'apps_to_run',
'apps_to_avoid',
'options',
],
)
print "before harvest"
@after.harvest
def after_harvest(results):
assert_equals(len(results), 2)
......
......@@ -79,6 +79,47 @@ def test_django_background_server_running_in_background():
FileSystem.popd()
def test_django_background_server_running_in_background_with_custom_port():
'the harvest command should take a --port argument'
FileSystem.pushd(current_directory, "django", "alfaces")
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
raise SystemExit()
def runserver():
application = tornado.web.Application([
(r"/", MainHandler),
])
application.listen(9889)
tornado.ioloop.IOLoop.instance().start()
server = multiprocessing.Process(target=runserver)
server.start()
time.sleep(1) # the child process take some time to get up
e = 'Lettuce could not run the builtin Django server at 0.0.0.0:9889"\n' \
'maybe you forgot a "runserver" instance running ?\n\n' \
'well if you really do not want lettuce to run the server ' \
'for you, then just run:\n\n' \
'python manage.py --no-server'
try:
status, out = commands.getstatusoutput(
"python manage.py harvest --verbosity=3 --port=9889")
assert_equals(out, e)
assert_not_equals(status, 0)
finally:
os.kill(server.pid, 9)
FileSystem.popd()
def test_limit_by_app_getting_all_apps_by_comma():
'running "harvest" with --apps=multiple,apps,separated,by,comma'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment