<s> import pytz <EOL> import datetime <EOL> from django . test . utils import override_settings <EOL> from django . test import TestCase <EOL> from django . core . urlresolvers import reverse <EOL> from schedule . models . calendars import Calendar <EOL> from schedule . models . events import Event <EOL> from schedule . models . rules import Rule <EOL> from schedule . views import coerce_date_dict <EOL> from schedule . conf . settings import USE_FULLCALENDAR <EOL> class TestViews ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . rule = Rule . objects . create ( frequency = "<STR_LIT>" ) <EOL> self . calendar = Calendar . objects . create ( name = "<STR_LIT>" , slug = '<STR_LIT>' ) <EOL> data = { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT:start>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT:0> , tzinfo = pytz . utc ) , <EOL> '<STR_LIT:end>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:9> , <NUM_LIT:0> , tzinfo = pytz . utc ) , <EOL> '<STR_LIT>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = pytz . utc ) , <EOL> '<STR_LIT>' : self . rule , <EOL> '<STR_LIT>' : self . calendar <EOL> } <EOL> self . event = Event . objects . create ( ** data ) <EOL> @ override_settings ( USE_TZ = False ) <EOL> def test_timezone_off ( self ) : <EOL> url = reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : self . calendar . slug } ) <EOL> response = self . client . get ( url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . client . login ( username = "<STR_LIT>" , password = "<STR_LIT>" ) <EOL> class TestViewUtils ( TestCase ) : <EOL> def test_coerce_date_dict ( self ) : <EOL> self . assertEqual ( <EOL> coerce_date_dict ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT:2>' , '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT:4>' } ) , <EOL> { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : <NUM_LIT:4> } <EOL> ) <EOL> def test_coerce_date_dict_partial ( self ) : <EOL> self . assertEqual ( <EOL> coerce_date_dict ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT:2>' } ) , <EOL> { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> } <EOL> ) <EOL> def test_coerce_date_dict_empty ( self ) : <EOL> self . assertEqual ( <EOL> coerce_date_dict ( { } ) , <EOL> { } <EOL> ) <EOL> def test_coerce_date_dict_missing_values ( self ) : <EOL> self . assertEqual ( <EOL> coerce_date_dict ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT:3>' } ) , <EOL> { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> } <EOL> ) <EOL> class TestUrls ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' ] <EOL> highest_event_id = <NUM_LIT:7> <EOL> def test_calendar_view ( self ) : <EOL> self . response = self . client . get ( <EOL> reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : '<STR_LIT>' } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . response . context [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . name , <EOL> "<STR_LIT>" ) <EOL> def test_calendar_month_view ( self ) : <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , <EOL> kwargs = { "<STR_LIT>" : '<STR_LIT>' } ) , <EOL> { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:11> } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . response . context [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . name , <EOL> "<STR_LIT>" ) <EOL> month = self . response . context [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> self . assertEqual ( ( month . start , month . end ) , <EOL> ( datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = pytz . utc ) , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = pytz . utc ) ) ) <EOL> def test_event_creation_anonymous_user ( self ) : <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , <EOL> kwargs = { "<STR_LIT>" : '<STR_LIT>' } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT> ) <EOL> def test_event_creation_authenticated_user ( self ) : <EOL> self . client . login ( username = "<STR_LIT>" , password = "<STR_LIT>" ) <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , <EOL> kwargs = { "<STR_LIT>" : '<STR_LIT>' } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> self . response = self . client . post ( reverse ( "<STR_LIT>" , <EOL> kwargs = { "<STR_LIT>" : '<STR_LIT>' } ) , <EOL> { '<STR_LIT:description>' : '<STR_LIT:description>' , <EOL> '<STR_LIT:title>' : '<STR_LIT:title>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT> ) <EOL> highest_event_id = self . highest_event_id <EOL> highest_event_id += <NUM_LIT:1> <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , <EOL> kwargs = { "<STR_LIT>" : highest_event_id } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> self . client . logout ( ) <EOL> def test_view_event ( self ) : <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : <NUM_LIT:1> } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> def test_delete_event_anonymous_user ( self ) : <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : <NUM_LIT:1> } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT> ) <EOL> def test_delete_event_authenticated_user ( self ) : <EOL> self . client . login ( username = "<STR_LIT>" , password = "<STR_LIT>" ) <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : <NUM_LIT:1> } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT:200> ) <EOL> if USE_FULLCALENDAR : <EOL> self . assertEqual ( self . response . context [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' , args = [ Event . objects . get ( id = <NUM_LIT:1> ) . calendar . slug ] ) ) <EOL> else : <EOL> self . assertEqual ( self . response . context [ '<STR_LIT>' ] , <EOL> reverse ( '<STR_LIT>' , args = [ Event . objects . get ( id = <NUM_LIT:1> ) . calendar . slug ] ) ) <EOL> self . response = self . client . post ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : <NUM_LIT:1> } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT> ) <EOL> self . response = self . client . get ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : <NUM_LIT:1> } ) , { } ) <EOL> self . assertEqual ( self . response . status_code , <NUM_LIT> ) <EOL> self . client . logout ( ) </s>
