'Test update detection for single name match with no
parent specified in import source (should always update the match)'

def testSingleNameMatchWithoutParentItem(self):

    db = current.db
    s3db = current.s3db
    assertEqual = self.assertEqual
    otable = s3db.org_organisation
    btable = s3db.org_organisation_branch
    query = (((otable.name == 'DeDupOrgB') | (otable.name == 'DeDupBranch1')) & (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">DeDupOrgB</data>\n                                <data    field="comments">updated</data>\n                </resource>\n                <resource    name="org_organisation">\n                                <data    field="name">DeDupBranch1</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 == 'DeDupOrgB') & (otable.deleted != True))
    rows = db(query).select(otable.id, otable.uuid, otable.comments)
    assertEqual(len(rows), 1)
    row = rows.first()
    assertEqual(row.uuid, 'DEDUPORGB')
    assertEqual(row.comments, 'updated')
    query = ((otable.name == 'DeDupBranch1') & (otable.deleted != True))
    rows = db(query).select(otable.id, otable.uuid, otable.comments)
    assertEqual(len(rows), 1)
    row = rows.first()
    assertEqual(row.uuid, 'DEDUPBRANCHA1')
    assertEqual(row.comments, 'updated')
