<s> from datetime import timedelta , datetime <EOL> from nose . tools import eq_ <EOL> from kitsune . announcements . tests import AnnouncementFactory <EOL> from kitsune . dashboards . readouts import CONTRIBUTOR_READOUTS <EOL> from kitsune . sumo . tests import TestCase <EOL> from kitsune . sumo . urlresolvers import reverse <EOL> from kitsune . users . tests import UserFactory <EOL> from kitsune . wiki . models import HelpfulVote , Document <EOL> from kitsune . wiki . tests import LocaleFactory , ApprovedRevisionFactory <EOL> class LocalizationDashTests ( TestCase ) : <EOL> def test_redirect_to_contributor_dash ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , <EOL> locale = '<STR_LIT>' ) , <EOL> follow = True ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' , <EOL> locale = '<STR_LIT>' ) ) <EOL> def LocalizationDashAnnouncementsTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . locale1 = LocaleFactory ( locale = '<STR_LIT>' ) <EOL> self . u1 = UserFactory ( ) <EOL> self . u2 = UserFactory ( ) <EOL> self . u3 = UserFactory ( ) <EOL> self . u1 . is_superuser = <NUM_LIT:1> <EOL> self . u1 . save ( ) <EOL> self . locale1 . leaders . add ( self . u2 ) <EOL> self . locale1 . save ( ) <EOL> self . announcement = AnnouncementFactory ( <EOL> creator = self . u2 , <EOL> locale = self . locale1 , <EOL> content = "<STR_LIT>" , <EOL> show_after = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_show_create ( self ) : <EOL> self . client . login ( username = self . u1 . username , password = '<STR_LIT>' ) <EOL> resp = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertContains ( resp , '<STR_LIT>' ) <EOL> def test_show_for_authed ( self ) : <EOL> self . client . login ( username = self . u2 . username , password = '<STR_LIT>' ) <EOL> resp = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertContains ( resp , '<STR_LIT>' ) <EOL> def test_hide_for_not_authed ( self ) : <EOL> self . client . login ( username = self . u3 . username , password = '<STR_LIT>' ) <EOL> resp = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertNotContains ( resp , '<STR_LIT>' ) <EOL> def test_hide_for_anon ( self ) : <EOL> resp = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertNotContains ( resp , '<STR_LIT>' ) <EOL> class ContributorDashTests ( TestCase ) : <EOL> def test_main_view ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , <EOL> locale = '<STR_LIT>' ) ) <EOL> eq_ ( <NUM_LIT:200> , response . status_code ) <EOL> def test_detail_view ( self ) : <EOL> """<STR_LIT>""" <EOL> readoutKey = CONTRIBUTOR_READOUTS . keys ( ) [ <NUM_LIT:0> ] <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , <EOL> args = [ CONTRIBUTOR_READOUTS [ readoutKey ] . slug ] , <EOL> locale = '<STR_LIT>' ) ) <EOL> eq_ ( <NUM_LIT:200> , response . status_code ) <EOL> def test_needs_change_comment_is_shown ( self ) : <EOL> assert Document . objects . count ( ) < <NUM_LIT:10> <EOL> change_comment = '<STR_LIT>' <EOL> ApprovedRevisionFactory ( <EOL> document__needs_change = True , <EOL> document__needs_change_comment = change_comment , <EOL> ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , locale = '<STR_LIT>' ) ) <EOL> eq_ ( <NUM_LIT:200> , response . status_code ) <EOL> assert change_comment in response . content <EOL> def _add_vote_in_past ( rev , vote , days_back ) : <EOL> v = HelpfulVote ( revision = rev , helpful = vote ) <EOL> v . created = v . created - timedelta ( days = days_back ) <EOL> v . save ( ) </s>
