<s> """<STR_LIT>""" <EOL> from django . test import TestCase <EOL> from django . test . client import Client <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . auth . models import User as DjangoUser <EOL> from treeio . core . models import User , Group , Perspective , ModuleSetting , Object <EOL> from treeio . documents . models import Folder , Document , File , WebLink <EOL> class DocumentsModelsTest ( TestCase ) : <EOL> "<STR_LIT>" <EOL> def test_model_folder ( self ) : <EOL> "<STR_LIT>" <EOL> obj = Folder ( name = '<STR_LIT:test>' ) <EOL> obj . save ( ) <EOL> self . assertEquals ( '<STR_LIT:test>' , obj . name ) <EOL> self . assertNotEquals ( obj . id , None ) <EOL> obj . delete ( ) <EOL> def test_model_document ( self ) : <EOL> "<STR_LIT>" <EOL> folder = Folder ( name = '<STR_LIT:test>' ) <EOL> folder . save ( ) <EOL> obj = Document ( title = '<STR_LIT:test>' , folder = folder ) <EOL> obj . save ( ) <EOL> self . assertEquals ( folder , obj . folder ) <EOL> self . assertNotEquals ( obj . id , None ) <EOL> obj . delete ( ) <EOL> def test_model_file ( self ) : <EOL> "<STR_LIT>" <EOL> folder = Folder ( name = '<STR_LIT:test>' ) <EOL> folder . save ( ) <EOL> obj = File ( name = '<STR_LIT:test>' , folder = folder ) <EOL> obj . save ( ) <EOL> self . assertEquals ( folder , obj . folder ) <EOL> self . assertNotEquals ( obj . id , None ) <EOL> obj . delete ( ) <EOL> def test_model_weblink ( self ) : <EOL> "<STR_LIT>" <EOL> folder = Folder ( name = '<STR_LIT:test>' ) <EOL> folder . save ( ) <EOL> obj = WebLink ( title = '<STR_LIT:test>' , folder = folder , url = '<STR_LIT:test>' ) <EOL> obj . save ( ) <EOL> self . assertEquals ( folder , obj . folder ) <EOL> self . assertNotEquals ( obj . id , None ) <EOL> obj . delete ( ) <EOL> class DocumentsViewsTest ( TestCase ) : <EOL> "<STR_LIT>" <EOL> username = "<STR_LIT:test>" <EOL> password = "<STR_LIT:password>" <EOL> prepared = False <EOL> def setUp ( self ) : <EOL> "<STR_LIT>" <EOL> if not self . prepared : <EOL> Object . objects . all ( ) . delete ( ) <EOL> self . group , created = Group . objects . get_or_create ( name = '<STR_LIT:test>' ) <EOL> duser , created = DjangoUser . objects . get_or_create ( <EOL> username = self . username ) <EOL> duser . set_password ( self . password ) <EOL> duser . save ( ) <EOL> self . user , created = User . objects . get_or_create ( user = duser ) <EOL> self . user . save ( ) <EOL> perspective , created = Perspective . objects . get_or_create ( <EOL> name = '<STR_LIT:default>' ) <EOL> perspective . set_default_user ( ) <EOL> perspective . save ( ) <EOL> ModuleSetting . set ( '<STR_LIT>' , perspective . id ) <EOL> self . folder = Folder ( name = '<STR_LIT:test>' ) <EOL> self . folder . set_default_user ( ) <EOL> self . folder . save ( ) <EOL> self . document = Document ( title = '<STR_LIT>' , folder = self . folder ) <EOL> self . document . set_default_user ( ) <EOL> self . document . save ( ) <EOL> self . file = File ( name = '<STR_LIT>' , folder = self . folder ) <EOL> self . file . set_default_user ( ) <EOL> self . file . save ( ) <EOL> self . link = WebLink ( title = '<STR_LIT:test>' , folder = self . folder , url = '<STR_LIT:test>' ) <EOL> self . link . set_default_user ( ) <EOL> self . link . save ( ) <EOL> self . client = Client ( ) <EOL> self . prepared = True <EOL> def test_index_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_index_documents_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_index_files_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_index_weblinks_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_folder_add ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( Folder . objects . count ( ) , <NUM_LIT:1> ) <EOL> post_data = { '<STR_LIT:name>' : '<STR_LIT:test>' } <EOL> response = self . client . post ( reverse ( '<STR_LIT>' ) , post_data ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT> ) <EOL> self . assertEquals ( Folder . objects . count ( ) , <NUM_LIT:2> ) <EOL> def test_folder_view_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_folder_edit_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_folder_delete_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_document_add ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( Document . objects . count ( ) , <NUM_LIT:1> ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> post_data = { '<STR_LIT:title>' : '<STR_LIT:test>' , <EOL> '<STR_LIT>' : self . folder , <EOL> } <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , post_data ) <EOL> def test_document_add_typed ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_document_view_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_document_edit_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_document_delete_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_file_view_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_file_edit_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_file_delete_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_weblink_add_typed ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_weblink_add ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( WebLink . objects . count ( ) , <NUM_LIT:1> ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> post_data = { '<STR_LIT:title>' : '<STR_LIT:test>' , <EOL> '<STR_LIT>' : self . folder , <EOL> '<STR_LIT:url>' : '<STR_LIT:test>' , <EOL> } <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , post_data ) <EOL> def test_weblink_view_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_weblink_edit_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_weblink_delete_login ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:username>' : self . username , '<STR_LIT:password>' : self . password } ) <EOL> self . assertRedirects ( response , '<STR_LIT:/>' ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertEquals ( response . status_code , <NUM_LIT:200> ) <EOL> def test_index ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_index_documents_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_index_files_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_index_weblinks_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_folder_add_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_folder_view_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_folder_edit_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_folder_delete_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_document_add_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_document_add_typed_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_document_view_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_document_edit_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_document_delete_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . document . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_file_view_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_file_edit_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_file_delete_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . file . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_weblink_add_typed_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . folder . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_weblink_add_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_weblink_view_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_weblink_edit_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) <EOL> def test_weblink_delete_out ( self ) : <EOL> "<STR_LIT>" <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . link . id ] ) ) <EOL> self . assertRedirects ( response , reverse ( '<STR_LIT>' ) ) </s>
