#NEWLINE# def testHierarchyFilterTypeOf( self ) : #NEWLINE# #INDENT# ' Test S3HierarchyFilter recognition of typeof queries ' #NEWLINE# uids = self . uids #NEWLINE# resource = current . s3db . resource ( 'typeof_hierarchy_reference' ) #NEWLINE# filter_widget = S3HierarchyFilter ( 'typeof_hierarchy_id' ) #NEWLINE# ids = str ( uids [ 'HIERARCHY1-1' ] ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id__belongs' : ids , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ids ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( values , [ ids ] ) #NEWLINE# ids = str ( uids [ 'HIERARCHY1-1' ] ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id__typeof' : ids , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ( str ( uids [ uid ] ) for uid in ( 'HIERARCHY1-1' , 'HIERARCHY1-1-1' , 'HIERARCHY1-1-2' ) ) ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# ids = ',' . join ( ( str ( _id ) for _id in ( uids [ 'HIERARCHY1-1' ] , uids [ 'HIERARCHY2-1' ] , None ) ) ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id__typeof' : ids , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ( str ( uids [ uid ] ) for uid in ( 'HIERARCHY1-1' , 'HIERARCHY1-1-1' , 'HIERARCHY1-1-2' , 'HIERARCHY2-1' , 'HIERARCHY2-1-1' , 'HIERARCHY2-1-2' ) ) ) #NEWLINE# expected . add ( None ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id$name__typeof' : 'Type 1-1' , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ( str ( uids [ uid ] ) for uid in ( 'HIERARCHY1-1' , 'HIERARCHY1-1-1' , 'HIERARCHY1-1-2' ) ) ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id$name__typeof' : 'Type 1-1,Type 2-1' , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ( str ( uids [ uid ] ) for uid in ( 'HIERARCHY1-1' , 'HIERARCHY1-1-1' , 'HIERARCHY1-1-2' , 'HIERARCHY2-1' , 'HIERARCHY2-1-1' , 'HIERARCHY2-1-2' ) ) ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id$name__typeof' : 'Type 1-3' , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id$name__typeof' : 'None' , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( set ( values ) , expected ) #NEWLINE# ids = str ( uids [ 'HIERARCHY1-1' ] ) #NEWLINE# get_vars = { #NEWLINE# #INDENT# '~.typeof_hierarchy_id__belongs' : ids , #NEWLINE# '~.typeof_hierarchy_id$name__typeof' : 'Type 1-1' , #NEWLINE# #UNINDENT# } #NEWLINE# variable = filter_widget . variable ( resource , get_vars ) #NEWLINE# expected = set ( ids ) #NEWLINE# values = filter_widget . _values ( get_vars , variable ) #NEWLINE# self . assertEqual ( values , [ ids ] )