<s> import datetime <EOL> import random <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . test import TestCase <EOL> from regressiontests . generic_views . models import Book <EOL> class ArchiveIndexViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def _make_books ( self , n , base_date ) : <EOL> for i in range ( n ) : <EOL> b = Book . objects . create ( <EOL> name = '<STR_LIT>' % i , <EOL> slug = '<STR_LIT>' % i , <EOL> pages = <NUM_LIT:100> + i , <EOL> pubdate = base_date - datetime . timedelta ( days = <NUM_LIT:1> ) ) <EOL> def test_archive_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Book . objects . dates ( '<STR_LIT>' , '<STR_LIT>' ) [ : : - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_archive_view_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>' ] , Book . objects . dates ( '<STR_LIT>' , '<STR_LIT>' ) [ : : - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) ) ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_empty_archive_view ( self ) : <EOL> Book . objects . all ( ) . delete ( ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> def test_allow_empty_archive_view ( self ) : <EOL> Book . objects . all ( ) . delete ( ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_archive_view_template ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Book . objects . dates ( '<STR_LIT>' , '<STR_LIT>' ) [ : : - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_archive_view_template_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>' ] , Book . objects . dates ( '<STR_LIT>' , '<STR_LIT>' ) [ : : - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_archive_view_invalid ( self ) : <EOL> self . assertRaises ( ImproperlyConfigured , self . client . get , '<STR_LIT>' ) <EOL> def test_paginated_archive_view ( self ) : <EOL> self . _make_books ( <NUM_LIT:20> , base_date = datetime . date . today ( ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Book . objects . dates ( '<STR_LIT>' , '<STR_LIT>' ) [ : : - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) [ <NUM_LIT:0> : <NUM_LIT:10> ] ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] . number , <NUM_LIT:2> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . all ( ) [ <NUM_LIT:10> : <NUM_LIT:20> ] ) ) <EOL> class YearArchiveViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_year_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_year_view_make_object_list ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ) ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> ) ) ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_year_view_empty ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> def test_year_view_allow_future ( self ) : <EOL> year = datetime . date . today ( ) . year + <NUM_LIT:1> <EOL> b = Book . objects . create ( name = "<STR_LIT>" , pages = <NUM_LIT> , pubdate = datetime . date ( year , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> res = self . client . get ( '<STR_LIT>' % year ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' % year ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> res = self . client . get ( '<STR_LIT>' % year ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ datetime . datetime ( year , <NUM_LIT:1> , <NUM_LIT:1> ) ] ) <EOL> def test_year_view_paginated ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> ) ) ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_year_view_invalid_pattern ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> class MonthArchiveViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_month_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , <EOL> list ( Book . objects . filter ( pubdate = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ) ) <EOL> def test_month_view_allow_empty ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:1> ) ) <EOL> url = datetime . date . today ( ) . strftime ( '<STR_LIT>' ) . lower ( ) <EOL> res = self . client . get ( url ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> def test_month_view_allow_future ( self ) : <EOL> future = ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT> ) ) . replace ( day = <NUM_LIT:1> ) <EOL> urlbit = future . strftime ( '<STR_LIT>' ) . lower ( ) <EOL> b = Book . objects . create ( name = "<STR_LIT>" , pages = <NUM_LIT> , pubdate = future ) <EOL> res = self . client . get ( '<STR_LIT>' % urlbit ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' % urlbit ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . date ( ) , b . pubdate ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ b ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , future ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , future ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ) ) <EOL> def test_month_view_paginated ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> , pubdate__month = <NUM_LIT:10> ) ) ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> , pubdate__month = <NUM_LIT:10> ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_custom_month_format ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> def test_month_view_invalid_pattern ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> def test_previous_month_without_content ( self ) : <EOL> "<STR_LIT>" <EOL> self . pubdate_list = [ <EOL> datetime . date ( <NUM_LIT> , month , day ) <EOL> for month , day in ( ( <NUM_LIT:9> , <NUM_LIT:1> ) , ( <NUM_LIT:10> , <NUM_LIT:2> ) , ( <NUM_LIT:11> , <NUM_LIT:3> ) ) <EOL> ] <EOL> for pubdate in self . pubdate_list : <EOL> name = str ( pubdate ) <EOL> Book . objects . create ( name = name , slug = name , pages = <NUM_LIT:100> , pubdate = pubdate ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:1> ) ) <EOL> class WeekArchiveViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_week_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , Book . objects . get ( pubdate = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT> ) ) <EOL> def test_week_view_allow_empty ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> def test_week_view_allow_future ( self ) : <EOL> future = datetime . date ( datetime . date . today ( ) . year + <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> b = Book . objects . create ( name = "<STR_LIT>" , pages = <NUM_LIT> , pubdate = future ) <EOL> res = self . client . get ( '<STR_LIT>' % future . year ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' % future . year ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ b ] ) <EOL> def test_week_view_paginated ( self ) : <EOL> week_start = datetime . date ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT> ) <EOL> week_end = week_start + datetime . timedelta ( days = <NUM_LIT:7> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__gte = week_start , pubdate__lt = week_end ) ) ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__gte = week_start , pubdate__lt = week_end ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_week_view_invalid_pattern ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> def test_week_start_Monday ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT> ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT> ) ) <EOL> class DayArchiveViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_day_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , <EOL> list ( Book . objects . filter ( pubdate = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ) ) <EOL> def test_day_view_allow_empty ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> url = datetime . date . today ( ) . strftime ( '<STR_LIT>' ) . lower ( ) <EOL> res = self . client . get ( url ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> def test_day_view_allow_future ( self ) : <EOL> future = ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT> ) ) <EOL> urlbit = future . strftime ( '<STR_LIT>' ) . lower ( ) <EOL> b = Book . objects . create ( name = "<STR_LIT>" , pages = <NUM_LIT> , pubdate = future ) <EOL> res = self . client . get ( '<STR_LIT>' % urlbit ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' % urlbit ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , [ b ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , future ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , future ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ) ) <EOL> def test_day_view_paginated ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> , pubdate__month = <NUM_LIT:10> , pubdate__day = <NUM_LIT:1> ) ) ) <EOL> self . assertEqual ( list ( res . context [ '<STR_LIT>' ] ) , list ( Book . objects . filter ( pubdate__year = <NUM_LIT> , pubdate__month = <NUM_LIT:10> , pubdate__day = <NUM_LIT:1> ) ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_next_prev_context ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . content , "<STR_LIT>" ) <EOL> def test_custom_month_format ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> def test_day_view_invalid_pattern ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> def test_today_view ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , datetime . date . today ( ) ) <EOL> class DateDetailViewTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> urls = '<STR_LIT>' <EOL> def test_date_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>' ] , Book . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Book . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_date_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>' ] , Book . objects . get ( slug = '<STR_LIT>' ) ) <EOL> def test_date_detail_custom_month_format ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , Book . objects . get ( pk = <NUM_LIT:1> ) ) <EOL> def test_date_detail_allow_future ( self ) : <EOL> future = ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT> ) ) <EOL> urlbit = future . strftime ( '<STR_LIT>' ) . lower ( ) <EOL> b = Book . objects . create ( name = "<STR_LIT>" , slug = "<STR_LIT>" , pages = <NUM_LIT> , pubdate = future ) <EOL> res = self . client . get ( '<STR_LIT>' % urlbit ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> res = self . client . get ( '<STR_LIT>' % ( urlbit , b . id ) ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , b ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_invalid_url ( self ) : <EOL> self . assertRaises ( AttributeError , self . client . get , "<STR_LIT>" ) </s>
