def testMultipleNameMatchesWithoutParentItemAmbiguous(self):

        db = current.db
        s3db = current.s3db

        assertEqual = self.assertEqual
        assertNotEqual = self.assertNotEqual
        assertTrue = self.assertTrue

        otable = s3db.org_organisation
        btable = s3db.org_organisation_branch

        # Verify that there are two DeDupOrgA (in pristine state)
        query = (otable.name == "DeDupBranch2") & \
                (otable.deleted != True)
        rows = db(query).select(otable.id, otable.comments)
        assertEqual(len(rows), 2)
        for row in rows:
            assertEqual(row.comments, None)

        # Import organisation with multiple name matches in the DB
        xmlstr = """
<s3xml>
    <resource name="org_organisation">
        <data field="name">DeDupBranch2</data>
        <data field="comments">updated</data>
    </resource>
</s3xml>"""

        xmltree = etree.ElementTree(etree.fromstring(xmlstr))

        resource = s3db.resource("org_organisation")
        result = resource.import_xml(xmltree, ignore_errors=True)

        # Verify that we have an error reported for the import item
        result = json.loads(result)
        msg = result["message"]

        error_tree = resource.error_tree
        assertNotEqual(error_tree, None)

        elements = error_tree.xpath("resource[data[@field='name']/text()='DeDupBranch2']")
        assertEqual(len(elements), 1)

        attrib = elements[0].attrib
        assertTrue("error" in attrib)
        assertTrue(attrib["error"] in msg)

        # Verify that nothing has changed in the database
        query = (otable.name == "DeDupBranch2") & \
                (otable.deleted != True)
        rows = db(query).select(otable.id, otable.comments)
        assertEqual(len(rows), 2)
        for row in rows:
            assertEqual(row.comments, None)

# =============================================================================
Test update detection for multiple name matches if no parent
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3db/org.py/OrgDeduplicationTests.testMultipleNameMatchesWithoutParentItemAmbiguous