<s> from __future__ import unicode_literals <EOL> from django . conf import settings <EOL> from django . test . client import Client <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . auth . models import User <EOL> from django . test import TestCase <EOL> import unittest <EOL> import os <EOL> from importd import env , NotSet , RaiseException <EOL> class BasicTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> try : <EOL> self . root = User . objects . get ( username = "<STR_LIT:root>" ) <EOL> except User . DoesNotExist : <EOL> self . root = User . objects . create_user ( <EOL> "<STR_LIT:root>" , "<STR_LIT>" , "<STR_LIT:root>" <EOL> ) <EOL> self . root . is_superuser = True <EOL> self . root . is_active = True <EOL> self . root . is_staff = True <EOL> self . root . save ( ) <EOL> def test_settings_module ( self ) : <EOL> self . assertEqual ( settings . SETTINGS_MODULE , "<STR_LIT>" ) <EOL> def test_appdir ( self ) : <EOL> self . assertTrue ( __file__ . startswith ( settings . APP_DIR + "<STR_LIT>" ) ) <EOL> def test_debug ( self ) : <EOL> self . assertFalse ( settings . DEBUG ) <EOL> def test_views_imported ( self ) : <EOL> self . assertTrue ( settings . VIEWS_IMPORTED ) <EOL> def test_signals_imported ( self ) : <EOL> self . assertTrue ( settings . SIGNALS_IMPORTED ) <EOL> def test_forms_imported ( self ) : <EOL> self . assertTrue ( settings . FORMS_IMPORTED ) <EOL> def test_view_with_d_decorator ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ "<STR_LIT>" ] , <NUM_LIT> ) <EOL> self . assertTemplateUsed ( response , "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> response . content . replace ( b'<STR_LIT:\r>' , b'<STR_LIT>' ) , b"<STR_LIT>" <EOL> ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_mounts ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . content , b"<STR_LIT>" ) <EOL> def test_static_mapped ( self ) : <EOL> c = Client ( ) <EOL> settings . DEBUG = True <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> settings . DEBUG = False <EOL> def test_static_outside_apps ( self ) : <EOL> c = Client ( ) <EOL> settings . DEBUG = True <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> settings . DEBUG = False <EOL> def test_admin ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertIn ( response . status_code , [ <NUM_LIT:200> , <NUM_LIT> ] ) <EOL> if response . status_code != <NUM_LIT> : <EOL> self . assertTrue ( response . context [ "<STR_LIT:user>" ] . is_anonymous ( ) ) <EOL> self . assertTrue ( c . login ( username = "<STR_LIT:root>" , password = "<STR_LIT:root>" ) ) <EOL> response = None <EOL> response = c . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( response . context [ "<STR_LIT:user>" ] . is_authenticated ( ) ) <EOL> def test_namespace_url_reverse ( self ) : <EOL> url = reverse ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , url ) <EOL> def test_view_with_blueprint ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . content , b'<STR_LIT>' ) <EOL> response = c . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . content , b'<STR_LIT>' ) <EOL> def test_use_same_blueprint_many_times ( self ) : <EOL> url = reverse ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , url ) <EOL> url = reverse ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , url ) <EOL> class EnvTest ( BasicTest ) : <EOL> def test_env ( self ) : <EOL> old = os . environ <EOL> os . environ = { } <EOL> with self . assertRaises ( KeyError ) : <EOL> env ( "<STR_LIT:foo>" , default = RaiseException ) <EOL> os . environ = { "<STR_LIT:foo>" : "<STR_LIT:bar>" } <EOL> self . assertEqual ( env ( "<STR_LIT:foo>" ) , "<STR_LIT:bar>" ) <EOL> self . assertEqual ( env ( "<STR_LIT:foo>" , default = False ) , True ) <EOL> self . assertEqual ( env ( "<STR_LIT:foo>" , default = False , factory = NotSet ) , "<STR_LIT:bar>" ) <EOL> for v in [ "<STR_LIT:0>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:False>" , "<STR_LIT:false>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> os . environ = { "<STR_LIT>" : v } <EOL> self . assertEqual ( env ( "<STR_LIT>" , default = False ) , False ) <EOL> os . environ = old </s>
