예제 #1
0
    def load_registry(self):
        if self.enabled and self.registryLoaded is False:
            # Load the registry here not in configuration,
            # because the configuration are not load in order of score
            self.registryLoaded = True
            BlokManager.load()
            load_init_function_from_entry_points(unittest=True)
            Configuration.load_config_for_test()
            Configuration.parse_options(self.AnyBlokOptions, ('bloks',))
            db_name = Configuration.get('db_name')
            if not db_name:
                raise Exception("No database defined to run Test")

            registry = RegistryManager.get(db_name)
            if registry:
                installed_bloks = registry.System.Blok.list_by_state(
                    "installed")
                selected_bloks = Configuration.get('selected_bloks')
                if not selected_bloks:
                    selected_bloks = installed_bloks

                unwanted_bloks = Configuration.get('unwanted_bloks')
                if unwanted_bloks is None:
                    unwanted_bloks = []

                self.bloks_path = [BlokManager.getPath(x)
                                   for x in BlokManager.ordered_bloks]

                self.authoried_bloks_test_files = [
                    path for blok in installed_bloks
                    if blok in selected_bloks and blok not in unwanted_bloks
                    for path in [join(BlokManager.getPath(blok), 'tests')]
                    if exists(path)]
                registry.close()  # free the registry to force create it again
예제 #2
0
파일: plugins.py 프로젝트: zakibelm/AnyBlok
    def load_registry(self):
        if not self.enabled or self.registryLoaded:
            return

        from anyblok.config import Configuration, get_db_name
        from anyblok import (
            load_init_function_from_entry_points,
            configuration_post_load,
        )
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager, return_list

        # Load the registry here not in configuration,
        # because the configurations are not loaded in order of score
        self.registryLoaded = True
        load_init_function_from_entry_points(unittest=True)
        Configuration.load_config_for_test()
        Configuration.parse_options(self.AnyBlokOptions)
        configuration_post_load()
        BlokManager.load()
        db_name = get_db_name()

        registry = RegistryManager.get(db_name)
        if not registry:
            return

        installed_bloks = registry.System.Blok.list_by_state("installed")
        selected_bloks = return_list(
            Configuration.get('selected_bloks')) or installed_bloks

        unwanted_bloks = return_list(Configuration.get('unwanted_bloks')) or []

        self.authorized_blok_paths = set(
            BlokManager.getPath(b) for b in BlokManager.list()
            if b in selected_bloks and b not in unwanted_bloks)

        test_dirs = self.authorized_blok_test_dirs = set()
        for startpath in self.authorized_blok_paths:
            for root, dirs, _ in walk(startpath):
                if 'tests' in dirs:
                    test_dirs.add(join(root, 'tests'))

        registry.close()  # free the registry to force create it again
예제 #3
0
파일: plugins.py 프로젝트: gracinet/AnyBlok
    def load_registry(self):
        if self.enabled and self.registryLoaded is False:
            # Load the registry here not in configuration,
            # because the configuration are not load in order of score
            self.registryLoaded = True
            load_init_function_from_entry_points(unittest=True)
            Configuration.load_config_for_test()
            Configuration.parse_options(self.AnyBlokOptions)
            configuration_post_load()
            BlokManager.load()
            db_name = get_db_name()

            registry = RegistryManager.get(db_name)
            if registry:
                installed_bloks = registry.System.Blok.list_by_state(
                    "installed")
                selected_bloks = return_list(
                    Configuration.get('selected_bloks')) or installed_bloks

                unwanted_bloks = return_list(
                    Configuration.get('unwanted_bloks')) or []

                self.bloks_path = [BlokManager.getPath(x)
                                   for x in BlokManager.ordered_bloks]

                self.authoried_bloks_test_files = []
                for blok in installed_bloks:
                    if blok not in selected_bloks or blok in unwanted_bloks:
                        continue

                    startpath = BlokManager.getPath(blok)
                    for root, dirs, _ in walk(startpath):
                        if 'tests' in dirs:
                            self.authoried_bloks_test_files.append(
                                join(root, 'tests'))

                registry.close()  # free the registry to force create it again
예제 #4
0
def init_session(request):
    # Init registry
    load_init_function_from_entry_points(unittest=True)
    Configuration.load_config_for_test()
    additional_setting = {'unittest': True}

    if len(BlokManager.list()) == 0:
        BlokManager.load()
    registry = RegistryManager.get(Configuration.get('db_name'),
                                   **additional_setting)
    registry.commit()
    # Add savepoint
    registry.begin_nested()

    @event.listens_for(registry.session, 'after_transaction_end')
    def restart_savepoint(session, transaction):
        if transaction.nested and not transaction._parent.nested:
            session.expire_all()
            session.begin_nested()

    logger.info('Creating registry')
    yield registry

    request.addfinalizer(registry.session.close)
예제 #5
0
# -*- coding: utf-8 -*-
# This file is a part of the AnyBlok project
#
#    Copyright (C) 2017 Jean-Sebastien SUZANNE <*****@*****.**>
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file,You can
# obtain one at http://mozilla.org/MPL/2.0/.
from anyblok.config import Configuration
from anyblok import (
        load_init_function_from_entry_points,
        configuration_post_load,
)


load_init_function_from_entry_points(unittest=True)
Configuration.load_config_for_test()
configuration_post_load(unittest=True)
예제 #6
0
# This file is a part of the AnyBlok project
#
#    Copyright (C) 2015 Jean-Sebastien SUZANNE <*****@*****.**>
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file,You can
# obtain one at http://mozilla.org/MPL/2.0/.
from anyblok.config import Configuration


Configuration.load_config_for_test()
예제 #7
0
def load_configuration():
    load_init_function_from_entry_points(unittest=True)
    Configuration.load_config_for_test()
    Configuration.parse_options(MockParser())
    configuration_post_load(unittest=True)