Commits

John Chandler committed d4fd656

Added functional tests

  • Participants
  • Parent commits 1ddf2ea

Comments (0)

Files changed (2)

fluidocalypse/tests/__init__.py

 from test_fluid_utils import *
+from test_views       import *

fluidocalypse/tests/test_views.py

+from django.test import TestCase
+
+class TestRootView( TestCase ):
+    """ Test the root URL view redirection """
+    def test_root_redirects_genre_search( self ):
+        """ Test the root view redirects to genre search """        
+        response = self.client.get( "/" )
+
+        #self.assertRedirects( response, "/search/genre" )  ## too slow
+        self.assertEqual( response.status_code, 302 )
+        self.assertEqual( response["Location"], "http://testserver/search/genre" )
+        
+    def test_root_no_slash_redirects_genre_search( self ):
+        """ Test the root view redirects to genre search """        
+        response = self.client.get( "" )
+
+        #self.assertRedirects( response, "/search/genre" )  ## too slow
+        self.assertEqual( response.status_code, 302 )
+        self.assertEqual( response["Location"], "http://testserver/search/genre" )
+
+
+class TestShowBand( TestCase ):
+    """ Test the show_band view """
+    def test_unknown_band( self ):
+        """ Test showing unknown band """
+        response = self.client.get( "/band/unknown_band_hsdgfhghsd" )
+
+        self.assertEqual( response.status_code, 404 )
+        
+    def test_known_band( self ):
+        """ Test showing known band """
+        response = self.client.get( "/band/Napalm%20Death" )
+
+        self.assertEqual( response.status_code, 200 )
+
+
+class TestShowGenre( TestCase ):
+    """ Test the show_genre view """
+    def test_unknown_genre( self ):
+        """ Test showing unknown genre """
+        response = self.client.get( "/genre/progessive_vegetarian_grindcore" )
+
+        self.assertEqual( response.status_code, 404 )
+
+    def test_known_genre( self ):
+        """ Test showing known genre """
+        response = self.client.get( "/genre/jazz" )
+
+        self.assertEqual( response.status_code, 200 )