<s> """<STR_LIT>""" <EOL> from datetime import datetime <EOL> from . import base <EOL> class ListViewTestCase ( base . FormViewTestCase , base . ListViewTestCase ) : <EOL> """<STR_LIT>""" <EOL> perm = None <EOL> def assertActionRequiresPermission ( self , action , permission = None ) : <EOL> """<STR_LIT>""" <EOL> if permission is None : <EOL> permission = self . perm <EOL> o = self . factory . create ( ) <EOL> form = self . get_form ( ) <EOL> name = "<STR_LIT>" . format ( action ) <EOL> self . assertTrue ( name not in form . fields ) <EOL> res = self . post ( <EOL> { <EOL> name : str ( o . id ) , <EOL> "<STR_LIT>" : <EOL> form . fields . get ( "<STR_LIT>" ) [ <NUM_LIT:0> ] . value <EOL> } , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> res . mustcontain ( "<STR_LIT>" ) <EOL> def test_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> o = self . factory . create ( ) <EOL> self . get_form ( ) . submit ( <EOL> name = "<STR_LIT>" , <EOL> index = <NUM_LIT:0> , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } <EOL> ) <EOL> self . assertTrue ( bool ( self . refresh ( o ) . deleted_on ) ) <EOL> def test_delete_requires_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertActionRequiresPermission ( "<STR_LIT>" ) <EOL> def test_create_link ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> res = self . get ( ) <EOL> self . assertElement ( res . html , "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> def test_create_link_requires_perms ( self ) : <EOL> """<STR_LIT>""" <EOL> res = self . get ( ) <EOL> self . assertElement ( res . html , "<STR_LIT:a>" , "<STR_LIT>" , count = <NUM_LIT:0> ) <EOL> class MTModelListTests ( object ) : <EOL> """<STR_LIT>""" <EOL> def test_clone ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> self . factory . create ( ) <EOL> res = self . get_form ( ) . submit ( <EOL> name = "<STR_LIT>" , <EOL> index = <NUM_LIT:0> , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } , <EOL> ) <EOL> self . assertElement ( <EOL> res . json [ "<STR_LIT:html>" ] , "<STR_LIT>" , "<STR_LIT:title>" , count = <NUM_LIT:2> ) <EOL> def test_clone_requires_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertActionRequiresPermission ( "<STR_LIT>" ) <EOL> def test_filter_by_creator ( self ) : <EOL> """<STR_LIT>""" <EOL> self . factory . create ( name = "<STR_LIT>" , user = self . user ) <EOL> self . factory . create ( name = "<STR_LIT>" ) <EOL> res = self . get ( params = { "<STR_LIT>" : self . user . id } ) <EOL> self . assertInList ( res , "<STR_LIT>" ) <EOL> self . assertNotInList ( res , "<STR_LIT>" ) <EOL> def test_default_sort_by_last_created ( self ) : <EOL> """<STR_LIT>""" <EOL> self . factory . create ( <EOL> name = "<STR_LIT>" , created_on = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> self . factory . create ( <EOL> name = "<STR_LIT>" , created_on = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> res = self . get ( ) <EOL> self . assertOrderInList ( res , "<STR_LIT>" , "<STR_LIT>" ) <EOL> class StatusListTests ( object ) : <EOL> """<STR_LIT>""" <EOL> def test_activate ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> s = self . factory . create ( status = "<STR_LIT>" ) <EOL> self . get_form ( ) . submit ( <EOL> name = "<STR_LIT>" , <EOL> index = <NUM_LIT:0> , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } , <EOL> ) <EOL> self . assertEqual ( self . refresh ( s ) . status , "<STR_LIT>" ) <EOL> def test_activate_requires_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertActionRequiresPermission ( "<STR_LIT>" , self . perm ) <EOL> def test_draft ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> s = self . factory . create ( status = "<STR_LIT>" ) <EOL> self . get_form ( ) . submit ( <EOL> name = "<STR_LIT>" , <EOL> index = <NUM_LIT:0> , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } , <EOL> ) <EOL> self . assertEqual ( self . refresh ( s ) . status , "<STR_LIT>" ) <EOL> def test_draft_requires_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertActionRequiresPermission ( "<STR_LIT>" , self . perm ) <EOL> def test_deactivate ( self ) : <EOL> """<STR_LIT>""" <EOL> self . add_perm ( self . perm ) <EOL> s = self . factory . create ( status = "<STR_LIT>" ) <EOL> self . get_form ( ) . submit ( <EOL> name = "<STR_LIT>" , <EOL> index = <NUM_LIT:0> , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } , <EOL> ) <EOL> self . assertEqual ( self . refresh ( s ) . status , "<STR_LIT>" ) <EOL> def test_deactivate_requires_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertActionRequiresPermission ( "<STR_LIT>" , self . perm ) </s>
