Skip to content

Commit

Permalink
Merge pull request #80 from IamShobe/feature/change_to_work_with_mana…
Browse files Browse the repository at this point in the history
…gepy

fixed the way rotest is launching django server
  • Loading branch information
osherdp committed Jul 23, 2018
2 parents 4b64ff7 + 869db34 commit a3504de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/rotest/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
-D, --daemon Run as a background process.
"""
from __future__ import print_function
import os
import sys
import subprocess

import django
import docopt

from rotest.common.config import RESOURCE_MANAGER_PORT
from rotest.common.config import RESOURCE_MANAGER_PORT, search_config_file
from rotest.management.server.main import ResourceManagerServer

if sys.platform != "win32":
Expand All @@ -37,8 +38,11 @@ def start_server(server_port, run_django_server, django_port):
try:
if run_django_server:
print("Running the Django server as well")
app_directory = os.path.dirname(search_config_file())
manage_py_location = os.path.join(app_directory, "manage.py")
django_process = subprocess.Popen(
["django-admin",
["python",
manage_py_location,
"runserver",
"0.0.0.0:{}".format(django_port)]
)
Expand Down
9 changes: 6 additions & 3 deletions tests/cli/test_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

import mock
Expand All @@ -23,9 +24,11 @@ def test_running_django_server(popen, capsys):
sys.argv = ["rotest", "server"]
main()

popen.assert_called_once_with(["django-admin",
"runserver",
"0.0.0.0:8000"])
popen.assert_called_once_with(
["python",
os.path.join(os.path.abspath(os.path.curdir), "manage.py"),
"runserver",
"0.0.0.0:8000"])

out, _ = capsys.readouterr()
assert "Running the Django server as well" in out
Expand Down

0 comments on commit a3504de

Please sign in to comment.