def cleanup(self): try: immom.getobject(self.topobject) immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.ccb_apply() immom.ccb_finalize() except Exception, ex: pass
def test0020_ObjectTree(self): immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) for n in xrange(1,5): dn = "TestClassId=%d,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getchildobjects(self.topobject) self.assertEqual( c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1' ]) immom.ccb_initialize() for n in xrange(30,35): dn = "TestClassId=%d,TestClassId=3,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) for n in xrange(20,23): dn = "TestClassId=%d,TestClassId=2,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getsubtree(self.topobject) self.assertEqual( c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1', 'TestClassId=20,TestClassId=2,TestClassId=1', 'TestClassId=21,TestClassId=2,TestClassId=1', 'TestClassId=22,TestClassId=2,TestClassId=1', 'TestClassId=30,TestClassId=3,TestClassId=1', 'TestClassId=31,TestClassId=3,TestClassId=1', 'TestClassId=32,TestClassId=3,TestClassId=1', 'TestClassId=33,TestClassId=3,TestClassId=1', 'TestClassId=34,TestClassId=3,TestClassId=1' ]) immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0020_ObjectTree(self): immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) for n in xrange(1, 5): dn = "TestClassId=%d,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getchildobjects(self.topobject) self.assertEqual(c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1' ]) immom.ccb_initialize() for n in xrange(30, 35): dn = "TestClassId=%d,TestClassId=3,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) for n in xrange(20, 23): dn = "TestClassId=%d,TestClassId=2,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getsubtree(self.topobject) self.assertEqual(c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1', 'TestClassId=20,TestClassId=2,TestClassId=1', 'TestClassId=21,TestClassId=2,TestClassId=1', 'TestClassId=22,TestClassId=2,TestClassId=1', 'TestClassId=30,TestClassId=3,TestClassId=1', 'TestClassId=31,TestClassId=3,TestClassId=1', 'TestClassId=32,TestClassId=3,TestClassId=1', 'TestClassId=33,TestClassId=3,TestClassId=1', 'TestClassId=34,TestClassId=3,TestClassId=1' ]) immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0030_ModifyObject(self): attrs = [ ('TestClassModId', 'SANAMET', [ 'CONFIG', 'RDN' ],[]), ('saint32t', 'SAINT32T', [ 'CONFIG', 'WRITABLE' ],[-11]), ('sauint32t', 'SAUINT32T', [ 'CONFIG', 'WRITABLE' ],[22]), ('saint64t', 'SAINT64T', [ 'CONFIG', 'WRITABLE' ],[-33]), ('sauint64t', 'SAUINT64T', [ 'CONFIG', 'WRITABLE' ],[44]), ('satimet', 'SATIMET', [ 'CONFIG', 'WRITABLE' ],[]), ('sanamet', 'SANAMET', [ 'CONFIG', 'WRITABLE' ],[]), ('safloatt', 'SAFLOATT', [ 'CONFIG', 'WRITABLE' ],[]), ('sadoublet', 'SADOUBLET', [ 'CONFIG', 'WRITABLE' ],[]), ('sastringt', 'SASTRINGT', ['CONFIG','WRITABLE','MULTI_VALUE'],[]), ('saanyt', 'SAANYT', [ 'CONFIG', 'WRITABLE' ],[]), ] immom.createclass('TestClassMod', 'CONFIG', attrs) nonemptyattr = lambda (n,t,v): v and not n.startswith('SaImm') # Set-up modobject = 'TestClassModId=1,' + self.topobject immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) immom.createobject(modobject, 'TestClassMod', []) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-11]), ('saint64t', 'SAINT64T', [-33L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L]) ]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L]) ]) # 'SAUINT64T' does not work. It seems like correct values are # stored, but signed values are read. immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [2147483647]), ('sauint32t', 'SAUINT32T', [ 4294967295 ]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']) ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [2147483647]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sauint32t', 'SAUINT32T', [4294967295]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]) ]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', []), ('saint64t', 'SAINT64T', []), ('sanamet', 'SANAMET', []), ('sastringt', 'SASTRINGT', []), ('sauint32t', 'SAUINT32T', []), ('sauint64t', 'SAUINT64T', []) ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']) ]) # Clean-up immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.ccb_apply() immom.ccb_finalize() immom.deleteclass('TestClassMod')
def test0030_ModifyObject(self): attrs = [ ('TestClassModId', 'SANAMET', ['CONFIG', 'RDN'], []), ('saint32t', 'SAINT32T', ['CONFIG', 'WRITABLE'], [-11]), ('sauint32t', 'SAUINT32T', ['CONFIG', 'WRITABLE'], [22]), ('saint64t', 'SAINT64T', ['CONFIG', 'WRITABLE'], [-33]), ('sauint64t', 'SAUINT64T', ['CONFIG', 'WRITABLE'], [44]), ('satimet', 'SATIMET', ['CONFIG', 'WRITABLE'], []), ('sanamet', 'SANAMET', ['CONFIG', 'WRITABLE'], []), ('safloatt', 'SAFLOATT', ['CONFIG', 'WRITABLE'], []), ('sadoublet', 'SADOUBLET', ['CONFIG', 'WRITABLE'], []), ('sastringt', 'SASTRINGT', ['CONFIG', 'WRITABLE', 'MULTI_VALUE'], []), ('saanyt', 'SAANYT', ['CONFIG', 'WRITABLE'], []), ] immom.createclass('TestClassMod', 'CONFIG', attrs) nonemptyattr = lambda (n, t, v): v and not n.startswith('SaImm') # Set-up modobject = 'TestClassModId=1,' + self.topobject immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) immom.createobject(modobject, 'TestClassMod', []) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-11]), ('saint64t', 'SAINT64T', [-33L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L])]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L])]) # 'SAUINT64T' does not work. It seems like correct values are # stored, but signed values are read. immom.ccb_initialize() immom.modifyobject( modobject, [('saint32t', 'SAINT32T', [2147483647]), ('sauint32t', 'SAUINT32T', [4294967295]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f'])]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [2147483647]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sauint32t', 'SAUINT32T', [4294967295]), ('sauint64t', 'SAUINT64T', [9223372036854775807L])]) immom.ccb_initialize() immom.modifyobject(modobject, [('saint32t', 'SAINT32T', []), ('saint64t', 'SAINT64T', []), ('sanamet', 'SANAMET', []), ('sastringt', 'SASTRINGT', []), ('sauint32t', 'SAUINT32T', []), ('sauint64t', 'SAUINT64T', [])]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1'])]) # Clean-up immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.ccb_apply() immom.ccb_finalize() immom.deleteclass('TestClassMod')