cleemesser avatar cleemesser committed 9e051fe

start work on autoreload testing

Comments (0)

Files changed (3)

tests/test_project.py

 import requests, sys, os, time
 import subprocess, StringIO
 import unittest
+import random
 
 PIDFILE = os.path.join(os.getcwd(),'test_project.pid')
 
         self._check_ok(self.session.options(url, data='', headers=headers))
         self._check_ok(self.session.patch(url, data='', headers=headers))
 
-
-
+    def test_autoreload(self):
+        if not hasattr(self, 'session'):
+            self.session = requests.Session()
+        r=self.session.get(r'http://localhost:8000/testautoreload')
+        self.assertTrue(r.status_code == 200)
+        print r.text
+        fp=open('testdjangoproject/testdjango/testdjango/autoload_test.py', 'w+')
+        fp.write('x=%d\n' % random.randint(0,100))
+        fp.close()
+        time.sleep(2) # allow time for reload
+        r=self.session.get(r'http://localhost:8000/testautoreload')
+        print r.status_code
+        self.assertTrue(r.status_code == 200)
+        print r.text
 
 
         

tests/testdjangoproject/testdjango/testdjango/urls.py

 
     url(r'^$', 'testdjango.views.index', name='index'),
     url(r'testajax/', 'testdjango.views.testajax', name='testajax'),
-                       
+    url(r'testautoreload/', 'testdjango.views.testautoreload', name='testautoreload'),
     #url(r'^$', TemplateView.as_view(template_name='base.html')),
 
     # Examples:

tests/testdjangoproject/testdjango/testdjango/views.py

 # RequestContext always uses django.core.context_processors.csrf
 from django.template import Context, RequestContext, loader
 from django.core.context_processors import csrf
-
+import autoload_test
 
 def index(request):
     template = loader.get_template('tests.html')
         return HttpResponse('here is the response to your ajax DELETE')
     else:
         return HttpResponse('here is the response to the unrecognized request method %s' %method)
-        # HttpResponseBadRequest ?
+        # HttpResponseBadRequest ?
+
+
+import autoload_test
+
+def testautoreload(request):
+    return HttpResponse("%s" % autoload_test.x)
+    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.