#NEWLINE# def test_create_column_grants( self ) : #NEWLINE# #INDENT# 'Create a table with colum-level privileges' #NEWLINE# inmap = self . std_map ( ) #NEWLINE# inmap [ 'schema public' ] . update ( { #NEWLINE# #INDENT# 'table t1' : { #NEWLINE# #INDENT# 'columns' : [ { #NEWLINE# #INDENT# 'c1' : { #NEWLINE# #INDENT# 'type' : 'integer' , #NEWLINE# 'privileges' : [ { #NEWLINE# #INDENT# 'user1' : [ 'insert' ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'c2' : { #NEWLINE# #INDENT# 'type' : 'text' , #NEWLINE# 'privileges' : [ { #NEWLINE# #INDENT# 'user1' : [ 'insert' ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'user2' : [ 'insert' , 'update' ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'owner' : self . db . user , #NEWLINE# 'privileges' : [ { #NEWLINE# #INDENT# self . db . user : [ 'all' ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'PUBLIC' : [ 'select' ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# sql = self . to_sql ( inmap ) #NEWLINE# assert ( len ( sql ) == 7 ) #NEWLINE# assert ( sql [ 2 ] == ( 'GRANT ALL ON TABLE t1 TO %s' % self . db . user ) ) #NEWLINE# assert ( sql [ 3 ] == ( GRANT_SELECT % 'PUBLIC' ) ) #NEWLINE# assert ( sql [ 4 ] == 'GRANT INSERT (c1) ON TABLE t1 TO user1' ) #NEWLINE# assert ( sql [ 5 ] == 'GRANT INSERT (c2) ON TABLE t1 TO user1' ) #NEWLINE# assert ( sql [ 6 ] == 'GRANT INSERT (c2), UPDATE (c2) ON TABLE t1 TO user2' )