<s> from __future__ import absolute_import , unicode_literals <EOL> import warnings <EOL> from django . contrib . admin . util import quote <EOL> from django . core . urlresolvers import reverse <EOL> from django . template . response import TemplateResponse <EOL> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> from . models import Action , Person , Car <EOL> @ override_settings ( PASSWORD_HASHERS = ( '<STR_LIT>' , ) ) <EOL> class AdminCustomUrlsTest ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> self . client . logout ( ) <EOL> def testBasicAddGet ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertIsInstance ( response , TemplateResponse ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def testAddWithGETArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( '<STR_LIT>' , { '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> def testBasicAddPost ( self ) : <EOL> """<STR_LIT>""" <EOL> post_data = { <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> "<STR_LIT:name>" : '<STR_LIT>' , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> } <EOL> response = self . client . post ( '<STR_LIT>' , post_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> def testAdminUrlsNoClash ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> url = reverse ( '<STR_LIT>' % Action . _meta . app_label , <EOL> args = ( quote ( '<STR_LIT>' ) , ) ) <EOL> response = self . client . get ( url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> url = reverse ( '<STR_LIT>' % Action . _meta . app_label , <EOL> args = ( quote ( "<STR_LIT>" ) , ) ) <EOL> response = self . client . get ( url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> @ override_settings ( PASSWORD_HASHERS = ( '<STR_LIT>' , ) ) <EOL> class CustomRedirects ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> self . client . logout ( ) <EOL> def test_post_save_add_redirect ( self ) : <EOL> """<STR_LIT>""" <EOL> post_data = { '<STR_LIT:name>' : '<STR_LIT>' , } <EOL> self . assertEqual ( Person . objects . count ( ) , <NUM_LIT:0> ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , post_data ) <EOL> persons = Person . objects . all ( ) <EOL> self . assertEqual ( len ( persons ) , <NUM_LIT:1> ) <EOL> self . assertRedirects ( <EOL> response , reverse ( '<STR_LIT>' , args = [ persons [ <NUM_LIT:0> ] . pk ] ) ) <EOL> def test_post_save_change_redirect ( self ) : <EOL> """<STR_LIT>""" <EOL> Person . objects . create ( name = '<STR_LIT>' ) <EOL> self . assertEqual ( Person . objects . count ( ) , <NUM_LIT:1> ) <EOL> person = Person . objects . all ( ) [ <NUM_LIT:0> ] <EOL> post_data = { '<STR_LIT:name>' : '<STR_LIT>' , } <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ person . pk ] ) , post_data ) <EOL> self . assertRedirects ( <EOL> response , reverse ( '<STR_LIT>' , args = [ person . pk ] ) ) <EOL> def test_post_url_continue ( self ) : <EOL> """<STR_LIT>""" <EOL> post_data = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:1>' } <EOL> self . assertEqual ( Car . objects . count ( ) , <NUM_LIT:0> ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , post_data ) <EOL> cars = Car . objects . all ( ) <EOL> self . assertEqual ( len ( cars ) , <NUM_LIT:1> ) <EOL> self . assertRedirects ( <EOL> response , reverse ( '<STR_LIT>' , args = [ cars [ <NUM_LIT:0> ] . pk ] ) ) </s>
