import unittest
from django.test.client import Client
from django.db import models
from app.models import FikanoteDB
from urlparse import urlparse

class EpisodeTest(unittest.TestCase):
    def setUp(self):
        # unittest requires to create Client everytime
        self.client = Client()
        self.episodes = FikanoteDB.objects.order_by('-date')

    def test_get_episode(self):
        for number in range(1 , len(self.episodes)):
            target = "/" + str(number) + "/"
            # GET request 
            response = self.client.get(target)
            # expect to return 200 OK 
            self.assertEqual(response.status_code, 200)

    def test_get_episode_incorrect_num(self):
        target = "/" + str(len(self.episodes)+1) + "/" # +1 for incorrect number.
        expectedPath = '/'
        # GET request 
        response = self.client.get(target)
        self.assertEqual(response.status_code, 301)
        self.assertEqual(urlparse(response['Location']).path, expectedPath)

        

@@ -998,16 +998,602 @@
 dPath)%0A%0A
+    def test_get_episode_incorrect_string1(self):%0A        target = %22/a12/%22 %0A        # GET request %0A        response = self.client.get(target)%0A        self.assertEqual(response.status_code, 404)%0A%0A    def test_get_episode_incorrect_string2(self):%0A        target = %22/12a/%22 %0A        # GET request %0A        response = self.client.get(target)%0A        self.assertEqual(response.status_code, 404)%0A%0A    def test_get_episode_incorrect_string3(self):%0A        target = %22/hoge/%22 %0A        # GET request %0A        response = self.client.get(target)%0A        self.assertEqual(response.status_code, 404)%0A%0A
         

add test case for 404 pattern #49 .