'Test merge of realms when merging two person entities'

def testMergeRealms(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    (org1, org2) = self.get_records()
    s3db = current.s3db
    org1_pe_id = s3db.pr_get_pe_id(org1)
    org2_pe_id = s3db.pr_get_pe_id(org2)
    person = Storage(first_name='Nxthga', realm_entity=org2_pe_id)
    ptable = s3db.pr_person
    person_id = ptable.insert(**person)
    person = ptable[person_id]
    assertEqual(person.realm_entity, org2_pe_id)
    success = self.resource.merge(self.id1, self.id2)
    assertTrue(success)
    person = ptable[person_id]
    assertEqual(person.realm_entity, org1_pe_id)
