<s> from __future__ import absolute_import <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . test import TestCase <EOL> from django . views . generic . base import View <EOL> from . models import Artist , Author , Page <EOL> class DetailViewTest ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_simple_object ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertIsInstance ( res . context [ '<STR_LIT>' ] , View ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_detail_by_pk ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_detail_by_custom_pk ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_detail_by_slug ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( slug = '<STR_LIT>' ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( slug = '<STR_LIT>' ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_detail_by_custom_slug ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( slug = '<STR_LIT>' ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( slug = '<STR_LIT>' ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_verbose_name ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Artist . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Artist . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_template_name ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_template_name_suffix ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_template_name_field ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Page . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Page . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_context_object_name ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_duplicated_context_object_name ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] , Author . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_invalid_url ( self ) : <EOL> self . assertRaises ( AttributeError , self . client . get , '<STR_LIT>' ) <EOL> def test_invalid_queryset ( self ) : <EOL> self . assertRaises ( ImproperlyConfigured , self . client . get , '<STR_LIT>' ) <EOL> def test_non_model_object_with_meta ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT:object>' ] . id , "<STR_LIT>" ) </s>
