#NEWLINE# def testCollectionCreatePolicy( self ) : #NEWLINE# #INDENT# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'user collection' , #NEWLINE# #UNINDENT# } , user = self . user ) #NEWLINE# self . assertStatus ( resp , 403 ) #NEWLINE# self . model ( 'setting' ) . set ( SettingKey . COLLECTION_CREATE_POLICY , { #NEWLINE# #INDENT# 'open' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'open collection' , #NEWLINE# #UNINDENT# } , user = self . user ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertTrue ( ( '_id' in resp . json ) ) #NEWLINE# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'open collection' , #NEWLINE# #UNINDENT# } , user = None ) #NEWLINE# self . assertStatus ( group , 401 ) #NEWLINE# group = self . model ( 'group' ) . createGroup ( name = 'coll. creators' , creator = self . admin ) #NEWLINE# self . model ( 'setting' ) . set ( SettingKey . COLLECTION_CREATE_POLICY , { #NEWLINE# #INDENT# 'open' : False , #NEWLINE# 'groups' : [ str ( group [ '_id' ] ) ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . model ( 'group' ) . addUser ( group = group , user = self . user ) #NEWLINE# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'group collection' , #NEWLINE# #UNINDENT# } , user = self . user ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertTrue ( ( '_id' in resp . json ) ) #NEWLINE# self . model ( 'group' ) . removeUser ( group = group , user = self . user ) #NEWLINE# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'group collection' , #NEWLINE# #UNINDENT# } , user = self . user ) #NEWLINE# self . assertStatus ( resp , 403 ) #NEWLINE# self . model ( 'setting' ) . set ( SettingKey . COLLECTION_CREATE_POLICY , { #NEWLINE# #INDENT# 'open' : False , #NEWLINE# 'users' : [ str ( self . user [ '_id' ] ) ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . request ( path = '/collection' , method = 'POST' , params = { #NEWLINE# #INDENT# 'name' : 'user collection' , #NEWLINE# #UNINDENT# } , user = self . user ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertTrue ( ( '_id' in resp . json ) )