Commits

cleemesser committed 000e876

fix last mediahandler reference to get correct import - testing actually caught this :-)

Comments (0)

Files changed (2)

django_wsgiserver/management/commands/runwsgiserver.py

 
 from socket import gethostname
 from django.core.management.base import BaseCommand
-import django_wsgiserver.mediahandler
+import django_wsgiserver.wsgiutil
 from django_wsgiserver import wsgiserver
 
 CPWSGI_HELP = r"""

tests/test_project.py

 
 import requests, sys, os, time
 import subprocess
+import unittest
 
 PIDFILE = os.path.join(os.getcwd(),'test_project.pid')
 
 def launch_project():
     """start django wsgiserver as daemon"""
     print "hello from launch project"
-    subprocess.call(["python", r"testdjangoproject/testdjango/manage.py", "runwsgiserver",
-                     "threads=10", "daemonize", "pidfile=%s" % PIDFILE])
-    return None
+    subprocess.call(["python", r"testdjangoproject/testdjango/manage.py",
+                     "runwsgiserver",
+                     "threads=10", "daemonize",
+                     "pidfile=%s" % PIDFILE])
+
 
 def stop_project():
-    print "hello from stop project"
-    subprocess.call(["python", r"testdjangoproject/testdjango/manage.py", "runwsgiserver", "stop", "pidfile=%s" % PIDFILE])
-    return None
+    print "olleh from stop project"
+    subprocess.call(["python", r"testdjangoproject/testdjango/manage.py", "runwsgiserver",
+                     "stop", "pidfile=%s" % PIDFILE])
+
     
 
+class TestDeveloperMode(unittest.TestCase):
+
+    def setUp(self):
+        launch_project()
+        time.sleep(1) # it takes a little time for the server to get started
+        self.session = requests.Session()
+
+    def test_django_root(self):
+        time.sleep(1)
+        r = self.session.get(r'http://localhost:8000/')
+        self.assertTrue(r.status_code in (200, 304))
+
+    def tearDown(self):
+        stop_project()
+    
+    
 
 def do_tests():
     session = requests.Session()
 
 ##### test autoload ####
 
-if __name__== '__main__':
+def main():
     try:    
         launch_project()
         print "started project"
         raw = raw_input("press to end")
         stop_project()
     except: # KeyboardInterrupt:
+        print sys.exc_info()
         stop_project()
 
 
+    
+if __name__== '__main__':
+    main()
+    # unittest.main()
 
 
+