Mark Lavin avatar Mark Lavin committed bdda137

Add test for invalid lookup name.

Comments (0)

Files changed (3)

selectable/tests/runtests.py

+#!/usr/bin/env python
 import os
 import sys
 

selectable/tests/urls.py

 from django.conf.urls.defaults import *
 
+handler404 = 'selectable.tests.views.test_404'
+handler500 = 'selectable.tests.views.test_500'
+
 urlpatterns = patterns('',
     (r'^selectable-tests/', include('selectable.urls')),
 )

selectable/tests/views.py

-from django.test.client import Client
+from django.core.urlresolvers import reverse
+from django.http import HttpResponseNotFound, HttpResponseServerError
 from django.utils import simplejson as json
 
 from selectable.tests import ThingLookup
 )
 
 
+def test_404(request):
+    return HttpResponseNotFound()
+
+
+def test_500(request):
+    return HttpResponseServerError()
+
+
 class SelectableViewTest(BaseSelectableTestCase):
     
     def setUp(self):
         super(SelectableViewTest, self).setUp()
-        self.client = Client()
         self.url = ThingLookup.url()
         self.lookup = ThingLookup()
         self.thing = self.create_thing()
         response = self.client.get(self.url, data)
         data = json.loads(response.content)
         self.assertEqual(len(data), 1)
+
+    def test_unknown_lookup(self):
+        unknown_url = reverse('selectable-lookup', args=["XXXXXXX"])
+        response = self.client.get(unknown_url)
+        self.assertEqual(response.status_code, 404)
             
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.