<s> import datetime <EOL> from django . db . models import get_model <EOL> from django . core . urlresolvers import reverse <EOL> from transifex . txcommon . tests import base <EOL> Resource = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> Release = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ReleasesViewsTests ( base . BaseTestCase ) : <EOL> def test_release_list ( self ) : <EOL> self . assertTrue ( self . project . releases . all ( ) ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertContains ( resp , self . release . name ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertContains ( resp , self . release . name ) <EOL> def test_release_list_noreleases ( self ) : <EOL> self . project . releases . all ( ) . delete ( ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> def test_release_details_resources ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> self . assertContains ( resp , "<STR_LIT>" % self . resource . source_entities . count ( ) ) <EOL> def test_release_language_detail ( self ) : <EOL> """<STR_LIT>""" <EOL> url = reverse ( '<STR_LIT>' , args = [ self . project . slug , self . release . slug , self . language_ar . code ] ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( url ) <EOL> self . assertContains ( resp , '<STR_LIT>' , status_code = <NUM_LIT:200> ) <EOL> def test_release_create_good_private_resources ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = self . client [ '<STR_LIT>' ] . post ( self . urls [ '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . project . id , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , } , follow = True ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( reverse ( '<STR_LIT>' , <EOL> args = [ self . project . slug , '<STR_LIT>' ] ) ) <EOL> self . assertContains ( resp , "<STR_LIT>" , status_code = <NUM_LIT:200> ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( reverse ( '<STR_LIT>' , <EOL> args = [ self . project . slug , '<STR_LIT>' ] ) ) <EOL> self . assertContains ( resp , "<STR_LIT>" , status_code = <NUM_LIT:200> ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( reverse ( '<STR_LIT>' , <EOL> args = [ self . project . slug , '<STR_LIT>' ] ) ) <EOL> self . assertContains ( resp , "<STR_LIT>" , status_code = <NUM_LIT:200> ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . get ( reverse ( '<STR_LIT>' , <EOL> args = [ self . project . slug , '<STR_LIT>' ] ) ) <EOL> self . team . members . add ( self . user [ '<STR_LIT>' ] ) <EOL> self . assertTrue ( self . user [ '<STR_LIT>' ] in self . team . members . all ( ) ) <EOL> self . assertContains ( resp , "<STR_LIT>" , status_code = <NUM_LIT:200> ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> def test_release_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = self . client [ '<STR_LIT>' ] . post ( self . urls [ '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . project . id , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , } , follow = True ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> release = Release . objects . get ( slug = '<STR_LIT>' , project = self . project ) <EOL> url = reverse ( '<STR_LIT>' , args = [ self . project . slug , release . slug ] ) <EOL> resp = self . client [ '<STR_LIT>' ] . post ( url , { } , follow = True ) <EOL> self . assertContains ( resp , "<STR_LIT>" , status_code = <NUM_LIT:200> ) <EOL> def test_release_create_bad_private_resources ( self ) : <EOL> """<STR_LIT>""" <EOL> self . project . maintainers . add ( self . user [ '<STR_LIT>' ] ) <EOL> self . assertFalse ( <EOL> self . user [ '<STR_LIT>' ] in self . project_private . maintainers . all ( ) <EOL> ) <EOL> r = self . client [ '<STR_LIT>' ] . post ( self . urls [ '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . project . id , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , } , follow = True ) <EOL> self . assertRaises ( <EOL> Release . DoesNotExist , self . project . releases . get , slug = '<STR_LIT>' <EOL> ) <EOL> self . assertTemplateUsed ( r , "<STR_LIT>" ) <EOL> self . assertContains ( r , "<STR_LIT>" ) <EOL> def test_add_release_button_shown_on_project_deatils_page ( self ) : <EOL> response = self . client [ '<STR_LIT>' ] . get ( self . urls [ '<STR_LIT>' ] ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' % self . urls [ '<STR_LIT>' ] ) <EOL> class AllReleaseTests ( base . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_no_resource ( self ) : <EOL> self . project . resources . all ( ) . delete ( ) <EOL> self . assertEquals ( self . project . releases . filter ( slug = '<STR_LIT>' ) . count ( ) , <NUM_LIT:0> ) <EOL> def _create_new_resource ( self ) : <EOL> self . res2 = Resource . objects . create ( <EOL> slug = "<STR_LIT>" , name = "<STR_LIT>" , <EOL> project = self . project , source_language = self . language_en , <EOL> i18n_type = '<STR_LIT>' ) <EOL> def test_first_resource ( self ) : <EOL> self . project . resources . all ( ) . delete ( ) <EOL> self . _create_new_resource ( ) <EOL> self . assertTrue ( self . res2 in <EOL> self . project . releases . get ( slug = '<STR_LIT>' ) . resources . all ( ) ) <EOL> def test_extra_resource ( self ) : <EOL> self . _create_new_resource ( ) <EOL> rel_resources = self . project . releases . get ( slug = '<STR_LIT>' ) . resources . all ( ) <EOL> self . assertTrue ( self . resource in rel_resources ) <EOL> self . assertTrue ( self . res2 in rel_resources ) <EOL> def test_extra_resource_deletion ( self ) : <EOL> self . _create_new_resource ( ) <EOL> self . res2 . delete ( ) <EOL> rel_resources = self . project . releases . get ( slug = '<STR_LIT>' ) . resources . all ( ) <EOL> self . assertTrue ( self . resource in rel_resources ) <EOL> self . assertFalse ( self . res2 in rel_resources ) <EOL> def test_all_resources_deleted_no_all_release ( self ) : <EOL> self . resource . delete ( ) <EOL> self . assertFalse ( self . project . releases . filter ( slug = '<STR_LIT>' ) . count ( ) ) <EOL> def test_reserved_slug ( self ) : <EOL> resp = self . client [ '<STR_LIT>' ] . post ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT:test>' , } ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> resp = self . client [ '<STR_LIT>' ] . post ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT:test>' , } ) <EOL> self . assertNotContains ( resp , "<STR_LIT>" ) <EOL> class ReleaseFormDateFieldsTests ( base . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> url = reverse ( '<STR_LIT>' , args = [ '<STR_LIT>' ] ) <EOL> def setUp ( self ) : <EOL> super ( ReleaseFormDateFieldsTests , self ) . setUp ( ) <EOL> self . data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> } <EOL> def tearDown ( self ) : <EOL> super ( ReleaseFormDateFieldsTests , self ) . tearDown ( ) <EOL> Release . objects . filter ( slug = '<STR_LIT>' , project__id = <NUM_LIT:1> ) . delete ( ) <EOL> def test_release_date ( self ) : <EOL> """<STR_LIT>""" <EOL> now = datetime . datetime . now ( ) <EOL> release_date = { <EOL> '<STR_LIT>' : now . strftime ( '<STR_LIT>' ) <EOL> } <EOL> self . data . update ( release_date ) <EOL> now = now + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> develfreeze_date = { <EOL> '<STR_LIT>' : now . strftime ( '<STR_LIT>' ) <EOL> } <EOL> self . data . update ( develfreeze_date ) <EOL> resp = self . client [ '<STR_LIT>' ] . post ( self . url , self . data ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) <EOL> def test_develfreeze_date ( self ) : <EOL> """<STR_LIT>""" <EOL> now = datetime . datetime . now ( ) <EOL> develfreeze_date = { <EOL> '<STR_LIT>' : now . strftime ( '<STR_LIT>' ) <EOL> } <EOL> self . data . update ( develfreeze_date ) <EOL> now = now + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> stringfreeze_date = { <EOL> '<STR_LIT>' : now . strftime ( '<STR_LIT>' ) <EOL> } <EOL> self . data . update ( stringfreeze_date ) <EOL> resp = self . client [ '<STR_LIT>' ] . post ( self . url , self . data ) <EOL> self . assertContains ( resp , "<STR_LIT>" ) </s>
