def tearDown(self): """ Clear the registry, unload the blok manager and drop the database """ if self.registry: self.registry.close() RegistryManager.clear() BlokManager.unload() super(DBTestCase, self).tearDown()
def termhandler(signum, frame): nonlocal running BlokManager.unload() if running: logger.info("Stopping worker process...") running = False else: logger.warning("Killing worker process...") return os._exit(1)
def tearDown(self): """ Clear the registry, unload the blok manager and drop the database """ if self.registry: self.registry.close() RegistryManager.clear() BlokManager.unload() clear_mappers() super(DBTestCase, self).tearDown()
def tearDown(self): """ Clear the registry, unload the blok manager and drop the database """ registry = RegistryManager.get(Configuration.get('db_name')) registry.close() RegistryManager.clear() BlokManager.unload() clear_mappers() self.__class__.dropdb() super(TestBlok, self).tearDown()
def test_start_function(self): BlokManager.unload() db_name = Configuration.get('db_name') or 'test_anyblok' db_driver_name = Configuration.get('db_driver_name') or 'postgresql' testargs = ['default', '--db-name', db_name, '--db-driver-name', db_driver_name] with patch.object(sys, 'argv', testargs): registry = start('default') assert registry is not None
def test_start_function(self): BlokManager.unload() db_name = Configuration.get('db_name') or 'test_anyblok' db_driver_name = Configuration.get('db_driver_name') or 'postgresql' testargs = ['default', '--db-name', db_name, '--db-driver-name', db_driver_name] with patch.object(sys, 'argv', testargs): registry = start('default') self.assertIsNotNone(registry)
def setUpClass(cls): """ Intialialise the configuration manager """ super(DBTestCase, cls).setUpClass() cls.init_configuration_manager() if cls.createdb(keep_existing=True): BlokManager.load(entry_points=('bloks', 'test_bloks')) registry = cls.getRegistry() registry.commit() registry.close() BlokManager.unload()
def base_loaded(request): url = Configuration.get('get_url')() if not database_exists(url): db_template_name = Configuration.get('db_template_name', None) create_database(url, template=db_template_name) BlokManager.load() registry = init_registry_with_bloks([], None) registry.commit() registry.close() BlokManager.unload()
def test_anyblok_core_loaded(self): BlokManager.load() is_exist = 'anyblok-core' in RegistryManager.loaded_bloks self.assertEqual(is_exist, True) anyblokcore = RegistryManager.loaded_bloks['anyblok-core'] self.assertEqual(len(anyblokcore['Core']['Base']), 1) self.assertEqual(len(anyblokcore['Core']['SqlBase']), 1) self.assertEqual(len(anyblokcore['Core']['SqlViewBase']), 1) self.assertEqual(len(anyblokcore['Core']['Session']), 1) self.assertEqual(len(anyblokcore['Core']['Query']), 1) self.assertEqual(len(anyblokcore['Core']['InstrumentedList']), 1) is_exist = 'Model.System' in anyblokcore['Model'] self.assertEqual(is_exist, True) BlokManager.unload()
def test_anyblok_core_loaded(self): BlokManager.load() is_exist = 'anyblok-core' in RegistryManager.loaded_bloks assert is_exist anyblokcore = RegistryManager.loaded_bloks['anyblok-core'] assert len(anyblokcore['Core']['Base']) == 1 assert len(anyblokcore['Core']['SqlBase']) == 1 assert len(anyblokcore['Core']['SqlViewBase']) == 1 assert len(anyblokcore['Core']['Session']) == 1 assert len(anyblokcore['Core']['Query']) == 1 assert len(anyblokcore['Core']['InstrumentedList']) == 1 is_exist = 'Model.System' in anyblokcore['Model'] assert is_exist BlokManager.unload()
def base_loaded(request, configuration_loaded): if sgdb_in(['MySQL', 'MariaDB']): return url = Configuration.get('get_url')() if not database_exists(url): db_template_name = Configuration.get('db_template_name', None) create_database(url, template=db_template_name) BlokManager.load() registry = init_registry_with_bloks([], None) registry.commit() registry.close() BlokManager.unload()
def tearDown(self): super(TestBlokManager, self).tearDown() BlokManager.unload()
def test_reload_blok(self): BlokManager.load() try: RegistryManager.reload() finally: BlokManager.unload()
def tearDownClass(cls): super(TestMigration, cls).tearDownClass() BlokManager.unload() RegistryManager.loaded_bloks = cls.loaded_bloks cls.dropdb()
def bloks_must_be_unloaded(self, request): request.addfinalizer(BlokManager.unload) BlokManager.unload()