#NEWLINE# def testSingleNameMatchWithParentItemMatch( self ) : #NEWLINE# #INDENT# '\n            Test update detection for single name match with parent\n            specified in source (matching parent => should update branch)\n        ' #NEWLINE# db = current . db #NEWLINE# s3db = current . s3db #NEWLINE# assertEqual = self . assertEqual #NEWLINE# otable = s3db . org_organisation #NEWLINE# btable = s3db . org_organisation_branch #NEWLINE# query = ( otable . name == 'DeDupBranch4' ) #NEWLINE# rows = db ( query ) . select ( otable . id , otable . comments ) #NEWLINE# assertEqual ( len ( rows ) , 1 ) #NEWLINE# assertEqual ( rows . first ( ) . comments , None ) #NEWLINE# branch_id = rows . first ( ) . id #NEWLINE# query = ( ( ( btable . branch_id == branch_id ) & ( btable . deleted != True ) ) & ( otable . id == btable . organisation_id ) ) #NEWLINE# rows = db ( query ) . select ( otable . id , otable . uuid ) #NEWLINE# assertEqual ( len ( rows ) , 1 ) #NEWLINE# assertEqual ( rows . first ( ) . uuid , 'DEDUPORGC' ) #NEWLINE# xmlstr = '\n<s3xml>\n    <resource name="org_organisation" tuid="PARENT">\n        <data field="name">DeDupOrgC</data>\n    </resource>\n    <resource name="org_organisation">\n        <data field="name">DeDupBranch4</data>\n        <data field="comments">updated</data>\n        <resource name="org_organisation_branch" alias="parent">\n            <reference field="organisation_id" resource="org_organisation" tuid="PARENT"/>\n        </resource>\n    </resource>\n</s3xml>' #NEWLINE# xmltree = etree . ElementTree ( etree . fromstring ( xmlstr ) ) #NEWLINE# resource = s3db . resource ( 'org_organisation' ) #NEWLINE# resource . import_xml ( xmltree , ignore_errors = True ) #NEWLINE# query = ( otable . name == 'DeDupBranch4' ) #NEWLINE# rows = db ( query ) . select ( otable . id , otable . comments ) #NEWLINE# assertEqual ( len ( rows ) , 1 ) #NEWLINE# assertEqual ( rows . first ( ) . comments , 'updated' ) #NEWLINE# branch_id = rows . first ( ) . id #NEWLINE# query = ( ( ( btable . branch_id == branch_id ) & ( btable . deleted != True ) ) & ( otable . id == btable . organisation_id ) ) #NEWLINE# rows = db ( query ) . select ( otable . id , otable . uuid ) #NEWLINE# assertEqual ( len ( rows ) , 1 ) #NEWLINE# assertEqual ( rows . first ( ) . uuid , 'DEDUPORGC' )