import os

from django.test import TestCase
from django.test import Client
from django.core.urlresolvers import reverse

from .utils import get_posts_data
from .templatetags.pages_tags import page_url


class BasicTestCase(TestCase):
    def setUp(self):
        self.client = Client()

    def testHome(self):
        response = self.client.get(reverse('pages:home'))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response.url, 'http://djangogirls.org/taipei')

    def testTutorials(self):
        data = get_posts_data(os.path.join('pages', 'posts', 'info.json'))

        for track in data['tutorials']['tracks']:
            for post in track['posts']:
                if post['target'].startswith('//') or '://' in post['target']:
                    continue
                response = self.client.get(page_url(post['target']))
                self.assertContains(response, post['title'])

@@ -71,53 +71,8 @@
 ient
-%0Afrom django.core.urlresolvers import reverse
 %0A%0Afr
@@ -182,16 +182,17 @@
 tCase):%0A
+%0A
     def 
@@ -299,29 +299,11 @@
 get(
-reverse('pages:home')
+'/'
 )%0A  
@@ -445,17 +445,884 @@
 Tutorial
-s
+List(self):%0A        posts_data = get_posts_data(os.path.join('pages', 'posts', 'info.json'))%0A%0A        response = self.client.get('/tutorials/')%0A        for track in posts_data%5B'tutorials'%5D%5B'tracks'%5D:%0A            for post in track%5B'posts'%5D:%0A                if post%5B'target'%5D.startswith('//') or '://' in post%5B'target'%5D:%0A                    continue%0A                post_block = (%0A                    '%3Ca href=%22/%7Btarget%7D/%22%3E'%0A                    '%3Cdiv class=%22tutorial-item%22%3E'%0A                    '%3Ch3%3E%7Btitle%7D%3C/h3%3E'%0A                    '%3Cp%3E%7Bdescription%7D%3C/p%3E'%0A                    '%3C/div%3E'%0A                    '%3C/a%3E'%0A                ).format(%0A                    target=post%5B'target'%5D, title=post%5B'title'%5D,%0A                    description=post%5B'description'%5D,%0A                )%0A                self.assertContains(response, post_block, html=True)%0A%0A    def testTutorialDetail
 (self):%0A

Test tutorial list page