<s> from __future__ import absolute_import <EOL> import datetime <EOL> import django . test <EOL> import mock <EOL> import os <EOL> from django . conf import settings <EOL> from . . models import Topic , Question <EOL> class FAQViewTests ( django . test . TestCase ) : <EOL> urls = '<STR_LIT>' <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . _oldtd = settings . TEMPLATE_DIRS <EOL> settings . TEMPLATE_DIRS = [ os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) ] <EOL> def tearDown ( self ) : <EOL> settings . TEMPLATE_DIRS = self . _oldtd <EOL> def test_submit_faq_get ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_submit_faq_post ( self , mock_messages ) : <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT:text>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = self . client . post ( '<STR_LIT>' , data ) <EOL> mock_messages . sucess . assert_called ( ) <EOL> self . assertRedirects ( response , "<STR_LIT>" ) <EOL> self . assert_ ( <EOL> Question . objects . filter ( text = data [ '<STR_LIT:text>' ] ) . exists ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_submit_thanks ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> def test_faq_index ( self ) : <EOL> response = self . client . get ( '<STR_LIT:/>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> self . assertQuerysetEqual ( <EOL> response . context [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> ) <EOL> self . assertEqual ( <EOL> response . context [ '<STR_LIT>' ] , <EOL> Question . objects . order_by ( '<STR_LIT>' ) [ <NUM_LIT:0> ] . updated_on <EOL> ) <EOL> def test_topic_detail ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> response . context [ '<STR_LIT>' ] , <EOL> Topic . objects . get ( slug = "<STR_LIT>" ) <EOL> ) <EOL> self . assertEqual ( <EOL> response . context [ '<STR_LIT>' ] , <EOL> Topic . objects . get ( slug = '<STR_LIT>' ) . questions . order_by ( '<STR_LIT>' ) [ <NUM_LIT:0> ] . updated_on <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> response . context [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> ) <EOL> def test_question_detail ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> response . context [ "<STR_LIT>" ] , <EOL> Question . objects . get ( slug = "<STR_LIT>" ) <EOL> ) </s>
