<s> import datetime <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . auth import get_user_model <EOL> from django . test import TestCase <EOL> from . . models import Minutes <EOL> User = get_user_model ( ) <EOL> class MinutesViewsTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> start_date = datetime . datetime . now ( ) <EOL> last_month = start_date - datetime . timedelta ( weeks = <NUM_LIT:4> ) <EOL> two_months = last_month - datetime . timedelta ( weeks = <NUM_LIT:4> ) <EOL> self . m1 = Minutes . objects . create ( <EOL> date = start_date , <EOL> content = '<STR_LIT>' , <EOL> is_published = False , <EOL> ) <EOL> self . m2 = Minutes . objects . create ( <EOL> date = last_month , <EOL> content = '<STR_LIT>' , <EOL> is_published = True , <EOL> ) <EOL> self . m3 = Minutes . objects . create ( <EOL> date = two_months , <EOL> content = '<STR_LIT>' , <EOL> is_published = True , <EOL> ) <EOL> self . admin_user = User . objects . create_user ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . admin_user . is_staff = True <EOL> self . admin_user . save ( ) <EOL> def test_list_view ( self ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertNotIn ( self . m1 , response . context [ '<STR_LIT>' ] ) <EOL> self . assertIn ( self . m2 , response . context [ '<STR_LIT>' ] ) <EOL> self . assertIn ( self . m3 , response . context [ '<STR_LIT>' ] ) <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertIn ( self . m1 , response . context [ '<STR_LIT>' ] ) <EOL> self . assertIn ( self . m2 , response . context [ '<STR_LIT>' ] ) <EOL> self . assertIn ( self . m3 , response . context [ '<STR_LIT>' ] ) <EOL> def test_detail_view ( self ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : self . m2 . date . strftime ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' : self . m2 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : self . m2 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> } ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . m2 , response . context [ '<STR_LIT>' ] ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> } ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : self . m1 . date . strftime ( "<STR_LIT>" ) . zfill ( <NUM_LIT:2> ) , <EOL> } ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . m1 , response . context [ '<STR_LIT>' ] ) </s>
