<s> """<STR_LIT>""" <EOL> from django . contrib . auth . models import User , Permission <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import TestCase <EOL> from django . test import Client <EOL> from djangocrud . tests . models import Foo <EOL> class CoreTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . client = Client ( ) <EOL> user = User . objects . create_user ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . foo = Foo . objects . create ( <EOL> bar = '<STR_LIT>' , baz = '<STR_LIT>' , qux = '<STR_LIT>' ) <EOL> content_type = ContentType . objects . get_for_model ( Foo ) <EOL> permissions = [ Permission . objects . get_or_create ( <EOL> codename = '<STR_LIT>' . format ( permission ) , <EOL> content_type = content_type ) [ <NUM_LIT:0> ] for permission in ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> user . user_permissions . set ( permissions ) <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> def test_index ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_detail_view ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . foo . id <EOL> } ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> def test_list_view ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( reverse ( <EOL> '<STR_LIT:index>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertQuerysetEqual ( <EOL> response . context [ '<STR_LIT>' ] , <EOL> [ repr ( self . foo ) ] ) <EOL> def test_delete_view ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . post ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . foo . id <EOL> } ) ) <EOL> self . assertRedirects ( <EOL> response , <EOL> reverse ( <EOL> '<STR_LIT:index>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> status_code = <NUM_LIT> , <EOL> target_status_code = <NUM_LIT:200> ) <EOL> count = Foo . objects . filter ( id = self . foo . id ) . count ( ) <EOL> self . assertEqual ( count , <NUM_LIT:0> ) <EOL> def test_create_view ( self ) : <EOL> """<STR_LIT>""" <EOL> for verb in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> response = getattr ( self . client , verb ) ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] . _meta . model , Foo ) <EOL> response = self . client . post ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> { '<STR_LIT:bar>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> { '<STR_LIT:bar>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertRedirects ( <EOL> response , <EOL> reverse ( <EOL> '<STR_LIT:index>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> status_code = <NUM_LIT> , <EOL> target_status_code = <NUM_LIT:200> ) <EOL> def test_udpate_view ( self ) : <EOL> """<STR_LIT>""" <EOL> for verb in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> response = getattr ( self . client , verb ) ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . foo . id <EOL> } ) ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] . _meta . model , Foo ) <EOL> response = self . client . post ( reverse ( <EOL> '<STR_LIT>' , <EOL> kwargs = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . foo . id <EOL> } ) , <EOL> { '<STR_LIT:bar>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertRedirects ( <EOL> response , <EOL> reverse ( <EOL> '<STR_LIT:index>' , <EOL> kwargs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> status_code = <NUM_LIT> , <EOL> target_status_code = <NUM_LIT:200> ) </s>
