def test0010_TopObject(self):
        self.assertRaises(immom.AisException,
                          immom.getobject, self.topobject)
        self.assertRaises(immom.AisException,
                          immom.createobject, self.topobject, 'TestClass', [])
        immom.ccb_initialize()
        self.assertRaises(immom.AisException,
                          immom.createobject,self.topobject,'InvalidClass', [])
        immom.createobject(self.topobject, 'TestClass', [])
        self.assertRaises(immom.AisException,
                          immom.getobject, self.topobject)
        immom.ccb_apply()
        immom.ccb_finalize()

        o = immom.getobject(self.topobject)
        o.sort()
        self.assertEqual(
            o, [
            ('SaImmAttrAdminOwnerName', 'SASTRINGT', ['TestAdmin']),
            ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']),
            ('SaImmAttrImplementerName', 'SASTRINGT', []),
            ('TestClassId', 'SANAMET', ['TestClassId=1'])
            ])

        immom.adminowner_clear('SA_IMM_SUBTREE', [self.topobject])
        o = immom.getobject(self.topobject)
        o.sort()
        self.assertEqual(
            o, [
            ('SaImmAttrAdminOwnerName', 'SASTRINGT', []),
            ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']),
            ('SaImmAttrImplementerName', 'SASTRINGT', []),
            ('TestClassId', 'SANAMET', ['TestClassId=1'])
            ])

        self.assertRaises(immom.AisException,
                          immom.deleteclass, 'TestClass')

        immom.ccb_initialize()
        immom.deleteobjects([self.topobject])
        immom.getobject(self.topobject)
        immom.ccb_apply()
        immom.ccb_finalize()
        self.assertRaises(immom.AisException,
                          immom.getobject, self.topobject)
    def test0010_TopObject(self):
        self.assertRaises(immom.AisException, immom.getobject, self.topobject)
        self.assertRaises(immom.AisException, immom.createobject,
                          self.topobject, 'TestClass', [])
        immom.ccb_initialize()
        self.assertRaises(immom.AisException, immom.createobject,
                          self.topobject, 'InvalidClass', [])
        immom.createobject(self.topobject, 'TestClass', [])
        self.assertRaises(immom.AisException, immom.getobject, self.topobject)
        immom.ccb_apply()
        immom.ccb_finalize()

        o = immom.getobject(self.topobject)
        o.sort()
        self.assertEqual(
            o, [('SaImmAttrAdminOwnerName', 'SASTRINGT', ['TestAdmin']),
                ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']),
                ('SaImmAttrImplementerName', 'SASTRINGT', []),
                ('TestClassId', 'SANAMET', ['TestClassId=1'])])

        immom.adminowner_clear('SA_IMM_SUBTREE', [self.topobject])
        o = immom.getobject(self.topobject)
        o.sort()
        self.assertEqual(o,
                         [('SaImmAttrAdminOwnerName', 'SASTRINGT', []),
                          ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']),
                          ('SaImmAttrImplementerName', 'SASTRINGT', []),
                          ('TestClassId', 'SANAMET', ['TestClassId=1'])])

        self.assertRaises(immom.AisException, immom.deleteclass, 'TestClass')

        immom.ccb_initialize()
        immom.deleteobjects([self.topobject])
        immom.getobject(self.topobject)
        immom.ccb_apply()
        immom.ccb_finalize()
        self.assertRaises(immom.AisException, immom.getobject, self.topobject)
        ## FIX: Delete current object !!!
        try:
            wo = self.getwo(args)
        except immom.AisException, ex:
            print 'Failed: ' + str(ex)
            return
        if not wo:
            print 'No Working Object (top)'
            return

        try:
            if self.hasCcb:
                immom.deleteobject([wo])
            else:
                self.do_ccb('create')
                immom.deleteobjects([wo])
                self.do_ccb('apply')
        except immom.AisException, ex:
            self.do_ccb('abort')
            print 'Failed (ccb aborted): ' + str(ex)

    def do_create(self, args):
        """Create an object.
        If no CCB is active a temporary CCB is used.
        Syntax: create <rdn | /dn> classname [attr=value ...]
        """
        argv = shlex.split(args)
        if len(argv) < 2:
            print "Too few parameters"
            return