def test_add_remove_collection(self): """Tests adding and removing a collection from a collection""" insmgr = CounterCollection('test_namespace') ctr = CounterCollection('nested_child') insmgr.add(ctr) self.assertRaises(ObjectExists, insmgr.add, ctr) insmgr.remove(ctr) self.assertRaises(ObjectNotExists, insmgr.remove, ctr)
def test_add_remove_counter(self): """Tests adding and removing a counter from a collection""" insmgr = CounterCollection('test_namespace', description=u'test') ctr = NumericValueCounter('a_counter') atr = NumericValueCounter('b_counter') insmgr.add(ctr) insmgr.add(atr) self.assertRaises(ObjectExists, insmgr.add, ctr) self.assertEquals(insmgr.description, u'test') insmgr.remove(ctr) self.assertRaises(ObjectNotExists, insmgr.remove, ctr) c_atr = insmgr.get('b_counter') self.assertEquals(c_atr, atr) self.assertRaises(ObjectNotExists, insmgr.get, 'c_counter') self.assertEquals(insmgr.get()[0], atr) self.assertEquals(len(insmgr.get()), 1)