'Test update detection for multiple name matches without parent
in source (single root org match => should update the root org)'

def testMultipleNameMatchesWithoutParentItemRootMatch(self):

    db = current.db
    s3db = current.s3db
    assertEqual = self.assertEqual
    otable = s3db.org_organisation
    btable = s3db.org_organisation_branch
    query = ((otable.name == 'DeDupOrgA') & (otable.deleted != True))
    rows = db(query).select(otable.id, otable.comments)
    assertEqual(len(rows), 2)
    for row in rows:
        assertEqual(row.comments, None)
    xmlstr = '\n<s3xml>\n                <resource    name="org_organisation">\n                                <data    field="name">DeDupOrgA</data>\n                                <data    field="comments">updated</data>\n                </resource>\n</s3xml>'
    xmltree = etree.ElementTree(etree.fromstring(xmlstr))
    resource = s3db.resource('org_organisation')
    resource.import_xml(xmltree, ignore_errors=True)
    query = ((otable.name == 'DeDupOrgA') & (otable.deleted != True))
    rows = db(query).select(otable.id, otable.uuid, otable.comments)
    assertEqual(len(rows), 2)
    for row in rows:
        if (row.uuid == 'DEDUPORGA'):
            assertEqual(row.comments, 'updated')
        else:
            assertEqual(row.comments, None)
