def test_add_core(self): class test: pass RegistryManager.add_core_in_register('test', test) self.assertInCore(test) assert RegistryManager.has_core_in_register('testCore', 'test')
def test_add_core(self): class test: pass RegistryManager.add_core_in_register('test', test) self.assertInCore(test) self.assertEqual( RegistryManager.has_core_in_register('testCore', 'test'), True)
def register(self, parent, name, cls_, **kwargs): """ Add new sub registry in the registry :param parent: Existing declaration :param name: Name of the new declaration to add it :param cls_: Class Interface to add in the declaration """ if not hasattr(parent, name): core = type(name, tuple(), {}) setattr(parent, name, core) if parent == Declarations: return RegistryManager.add_core_in_register(name, cls_)
def test_remove_core(self): class test: pass def has_test_in_removed(): core = RegistryManager.loaded_bloks['testCore']['removed'] if test in core: return True return False RegistryManager.add_core_in_register('test', test) self.assertInCore(test) self.assertEqual(has_test_in_removed(), False) RegistryManager.remove_in_register(test) self.assertEqual(has_test_in_removed(), True)
def test_remove_core(self): class test: pass def has_test_in_removed(): core = RegistryManager.loaded_bloks['testCore']['removed'] if test in core: return True return False RegistryManager.add_core_in_register('test', test) self.assertInCore(test) assert not has_test_in_removed() RegistryManager.remove_in_register(test) assert has_test_in_removed()