<s> from __future__ import unicode_literals <EOL> from django . test import TestCase <EOL> from django . core . urlresolvers import reverse <EOL> from django . core . cache import cache <EOL> from ... core . tests import utils <EOL> from . models import Flag , CommentFlag <EOL> from . forms import FlagForm <EOL> class FlagViewTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> cache . clear ( ) <EOL> self . user = utils . create_user ( ) <EOL> self . category = utils . create_category ( ) <EOL> self . topic = utils . create_topic ( category = self . category , user = self . user ) <EOL> self . comment = utils . create_comment ( user = self . user , topic = self . topic ) <EOL> def test_flag_create ( self ) : <EOL> """<STR_LIT>""" <EOL> utils . login ( self ) <EOL> form_data = { '<STR_LIT>' : "<STR_LIT:0>" , } <EOL> response = self . client . post ( reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : self . comment . pk , } ) , <EOL> form_data ) <EOL> self . assertRedirects ( response , self . comment . get_absolute_url ( ) , status_code = <NUM_LIT> , target_status_code = <NUM_LIT> ) <EOL> self . assertEqual ( len ( Flag . objects . all ( ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( CommentFlag . objects . all ( ) ) , <NUM_LIT:1> ) <EOL> class FlagFormTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> cache . clear ( ) <EOL> self . user = utils . create_user ( ) <EOL> self . category = utils . create_category ( ) <EOL> self . topic = utils . create_topic ( category = self . category , user = self . user ) <EOL> self . comment = utils . create_comment ( user = self . user , topic = self . topic ) <EOL> def test_flag_create ( self ) : <EOL> """<STR_LIT>""" <EOL> form_data = { '<STR_LIT>' : '<STR_LIT:0>' , '<STR_LIT:body>' : '<STR_LIT>' } <EOL> form = FlagForm ( data = form_data ) <EOL> form . comment = self . comment <EOL> form . user = self . user <EOL> self . assertEqual ( form . is_valid ( ) , True ) <EOL> form . save ( ) <EOL> self . assertEqual ( len ( CommentFlag . objects . all ( ) ) , <NUM_LIT:1> ) </s>
