Example #1
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config
    config['db_name'] = args.database

    if args.tests:
        config['log_handler'] = [':INFO']
        config['test_enable'] = True
        config['without_demo'] = False
        if args.port:
            config['xmlrpc_port'] = int(args.port)
    else:
        config['log_handler'] = [':CRITICAL']
        config['test_enable'] = False
        config['without_demo'] = True

    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']
    config['init'] = dict.fromkeys(module_names, 1)

    if args.coverage:
        import coverage
        # Without the `include` kwarg, coverage generates 'memory:0xXXXXX'
        # filenames (which do not exist) and cause it to crash. No idea why.
        cov = coverage.coverage(branch=True, include='*.py')
        cov.start()
    openerp.netsvc.init_logger()

    if not args.no_create:
        with lock_file('/tmp/global_openerp_create_database.lock'):
            openerp.service.db._create_empty_database(args.database)

    config['workers'] = False

    rc = openerp.service.server.start(preload=[args.database], stop=True)

    if args.coverage:
        cov.stop()
        cov.html_report(directory='coverage')
        # If we wanted the report on stdout:
        # cov.report()

    sys.exit(rc)
Example #2
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config
    config['db_name'] = args.database

    if args.tests:
        config['log_handler'] = [':INFO']
        config['test_enable'] = True
        config['without_demo'] = False
        if args.port:
            config['xmlrpc_port'] = int(args.port)
    else:
        config['log_handler'] = [':CRITICAL']
        config['test_enable'] = False
        config['without_demo'] = True

    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']
    config['init'] = dict.fromkeys(module_names, 1)

    if args.coverage:
        import coverage
        # Without the `include` kwarg, coverage generates 'memory:0xXXXXX'
        # filenames (which do not exist) and cause it to crash. No idea why.
        cov = coverage.coverage(branch=True, include='*.py')
        cov.start()
    openerp.netsvc.init_logger()

    if not args.no_create:
        with lock_file('/tmp/global_openerp_create_database.lock'):
            openerp.service.db._create_empty_database(args.database)

    config['workers'] = False

    rc = openerp.service.server.start(preload=[args.database], stop=True)

    if args.coverage:
        cov.stop()
        cov.html_report(directory='coverage')
        # If we wanted the report on stdout:
        # cov.report()

    sys.exit(rc)
def run(args):
    import unittest2

    import openerp

    config = openerp.tools.config
    config['db_name'] = args.database
    if args.port:
        config['xmlrpc_port'] = int(args.port)
    config['admin_passwd'] = 'admin'
    config['db_password'] = '******'  # TODO from .openerpserverrc

    if args.addons:
        args.addons = args.addons.replace(':', ',').split(',')
    else:
        args.addons = []

    # ensure no duplication in addons paths
    args.addons = list(set(args.addons))
    config['addons_path'] = ','.join(args.addons)

    import logging
    openerp.netsvc.init_alternative_logger()
    logging.getLogger('openerp').setLevel(logging.CRITICAL)

    # Install the import hook, to import openerp.addons.<module>.
    openerp.modules.module.initialize_sys_path()

    module = args.module
    submodule = args.submodule

    # Import the necessary modules and get the corresponding suite.
    if module is None:
        # TODO
        modules = common.get_addons_from_paths(
            args.addons, [])  # TODO openerp.addons.base is not included ?
        test_modules = []
        for module in ['openerp'] + modules:
            test_modules.extend(
                get_test_modules(module, submodule, explode=False))
    else:
        test_modules = get_test_modules(module, submodule, explode=True)

    print 'Test modules:'
    for test_module in test_modules:
        print '    ', test_module.__name__
    print
    sys.stdout.flush()

    if not args.dry_run:
        suite = unittest2.TestSuite()
        for test_module in test_modules:
            suite.addTests(
                unittest2.TestLoader().loadTestsFromModule(test_module))
        r = unittest2.TextTestRunner(verbosity=2).run(suite)
        if r.errors or r.failures:
            sys.exit(1)
def run(args):
    import unittest2

    import openerp

    config = openerp.tools.config
    config.load()

    config['db_name'] = args.database
    if args.port:
        config['xmlrpc_port'] = int(args.port)

    if args.addons:
        args.addons = args.addons.replace(':',',').split(',')
    else:
        args.addons = []

    # ensure no duplication in addons paths
    args.addons = list(set(args.addons))
    config['addons_path'] = ','.join(args.addons)

    import logging
    openerp.netsvc.init_alternative_logger()
    logging.getLogger('openerp').setLevel(logging.CRITICAL)

    # Install the import hook, to import openerp.addons.<module>.
    openerp.modules.module.initialize_sys_path()

    module = args.module
    submodule = args.submodule

    # Import the necessary modules and get the corresponding suite.
    if module is None:
        # TODO
        modules = common.get_addons_from_paths(args.addons, []) # TODO openerp.addons.base is not included ?
        test_modules = []
        for module in ['openerp'] + modules:
            test_modules.extend(
                get_test_modules(module, submodule, explode=False))
    else:
        test_modules = get_test_modules(module, submodule, explode=True)

    print 'Test modules:'
    for test_module in test_modules:
        print '    ', test_module.__name__
    print
    sys.stdout.flush()

    if not args.dry_run:
        suite = unittest2.TestSuite()
        for test_module in test_modules:
            suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_module))
        r = unittest2.TextTestRunner(verbosity=2).run(suite)
        if r.errors or r.failures:
            sys.exit(1)
Example #5
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config

    if args.tests:
        config['log_handler'] = [':INFO']
        config['test_enable'] = True
        config['without_demo'] = False
    else:
        config['log_handler'] = [':CRITICAL']
        config['test_enable'] = False
        config['without_demo'] = True

    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']

    if args.coverage:
        import coverage
        # Without the `include` kwarg, coverage generates 'memory:0xXXXXX'
        # filenames (which do not exist) and cause it to crash. No idea why.
        cov = coverage.coverage(branch=True, include='*.py')
        cov.start()
    openerp.netsvc.init_logger()
    registry = install_openerp(args.database, not args.no_create, module_names,
                               not config['without_demo'])
    if args.coverage:
        cov.stop()
        cov.html_report(directory='coverage')
        # If we wanted the report on stdout:
        # cov.report()

    # The `_assertion_report` attribute was added on the registry during the
    # OpenERP 7.0 development.
    if hasattr(registry, '_assertion_report'):
        sys.exit(1 if registry._assertion_report.failures else 0)
Example #6
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config

    if args.tests:
        config['log_handler'] = [':TEST']
        config['test_enable'] = True
        config['without_demo'] = False
    else:
        config['log_handler'] = [':CRITICAL']
        config['test_enable'] = False
        config['without_demo'] = True

    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']

    if args.coverage:
        import coverage
        # Without the `include` kwarg, coverage generates 'memory:0xXXXXX'
        # filenames (which do not exist) and cause it to crash. No idea why.
        cov = coverage.coverage(branch=True, include='*.py')
        cov.start()
    openerp.netsvc.init_logger()
    registry = install_openerp(args.database, not args.no_create, module_names, not config['without_demo'])
    if args.coverage:
        cov.stop()
        cov.html_report(directory='coverage')
        # If we wanted the report on stdout:
        # cov.report()

    # The `_assertion_report` attribute was added on the registry during the
    # OpenERP 7.0 development.
    if hasattr(registry, '_assertion_report'):
        sys.exit(1 if registry._assertion_report.failures else 0)
Example #7
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config
    config['log_handler'] = [':CRITICAL']
    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)
    openerp.netsvc.init_logger()

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']

    install_openerp(args.database, not args.no_create, module_names)
Example #8
0
def run(args):
    assert args.database
    assert not (args.module and args.all_modules)

    import openerp

    config = openerp.tools.config

    if args.tests:
        config['log_handler'] = [':TEST']
        config['test_enable'] = True
        config['without_demo'] = False
    else:
        config['log_handler'] = [':CRITICAL']
        config['test_enable'] = False
        config['without_demo'] = True

    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    config['addons_path'] = ','.join(args.addons)

    if args.all_modules:
        module_names = common.get_addons_from_paths(args.addons, args.exclude)
    elif args.module:
        module_names = args.module
    else:
        module_names = ['base']

    openerp.netsvc.init_logger()
    registry = install_openerp(args.database, not args.no_create, module_names, not config['without_demo'])

    # The `_assertion_report` attribute was added on the registry during the
    # OpenERP 7.0 development.
    if hasattr(registry, '_assertion_report'):
        sys.exit(1 if registry._assertion_report.failures else 0)
Example #9
0
def run(args):
    import unittest2

    import openerp

    config = openerp.tools.config
    config['db_name'] = args.database
    config['addons_path'] = args.addons.replace(':',',')
    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    if args.sanity_checks and args.fast_suite:
        print 'Only at most one of `--sanity-checks` and `--fast-suite` ' \
            'can be specified.'
        sys.exit(1)

    # Install the import hook, to import openerp.addons.<module>.
    openerp.modules.module.initialize_sys_path()
    openerp.modules.loading.open_openerp_namespace()

    # Extract module, submodule from the command-line args.
    if args.module is None:
        module, submodule = None, None
    else:
        splitted = args.module.split('.')
        if len(splitted) == 1:
            module, submodule = splitted[0], None
        elif len(splitted) == 2:
            module, submodule = splitted
        else:
            print 'The `module` argument must have the form ' \
                '`module[.submodule]`.'
            sys.exit(1)

    # Import the necessary modules and get the corresponding suite.
    if module is None:
        # TODO
        modules = common.get_addons_from_paths(args.addons, []) # TODO openerp.addons.base is not included ?
	test_modules = []
        for module in ['openerp'] + modules:
            if args.fast_suite:
                submodule = '__fast_suite__'
            if args.sanity_checks:
                submodule = '__sanity_checks__'
            test_modules.extend(get_test_modules(module,
                submodule, explode=False))
    else:
        if submodule and args.fast_suite:
            print "Submodule name `%s` given, ignoring `--fast-suite`." % (submodule,)
        if submodule and args.sanity_checks:
            print "Submodule name `%s` given, ignoring `--sanity-checks`." % (submodule,)
        if not submodule and args.fast_suite:
            submodule = '__fast_suite__'
        if not submodule and args.sanity_checks:
            submodule = '__sanity_checks__'
        test_modules = get_test_modules(module,
            submodule, explode=True)

    # Run the test suite.
    if not args.dry_run:
        suite = unittest2.TestSuite()
        for test_module in test_modules:
            suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_module))
        unittest2.TextTestRunner(verbosity=2).run(suite)
    else:
        print 'Test modules:'
        for test_module in test_modules:
            print ' ', test_module.__name__
Example #10
0
def run(args):
    import unittest2

    import openerp

    config = openerp.tools.config
    config['db_name'] = args.database
    if args.port:
        config['xmlrpc_port'] = int(args.port)
    config['admin_passwd'] = 'admin'
    config['db_password'] = '******' # TODO from .openerpserverrc
    config['addons_path'] = args.addons.replace(':',',')
    if args.addons:
        args.addons = args.addons.split(':')
    else:
        args.addons = []
    if args.sanity_checks and args.fast_suite:
        print 'Only at most one of `--sanity-checks` and `--fast-suite` ' \
            'can be specified.'
        sys.exit(1)

    import logging
    openerp.netsvc.init_alternative_logger()
    logging.getLogger('openerp').setLevel(logging.CRITICAL)

    # Install the import hook, to import openerp.addons.<module>.
    openerp.modules.module.initialize_sys_path()

    # Extract module, submodule from the command-line args.
    if args.module is None:
        module, submodule = None, None
    else:
        splitted = args.module.split('.')
        if len(splitted) == 1:
            module, submodule = splitted[0], None
        elif len(splitted) == 2:
            module, submodule = splitted
        else:
            print 'The `module` argument must have the form ' \
                '`module[.submodule]`.'
            sys.exit(1)

    # Import the necessary modules and get the corresponding suite.
    if module is None:
        # TODO
        modules = common.get_addons_from_paths(args.addons, []) # TODO openerp.addons.base is not included ?
	test_modules = []
        for module in ['openerp'] + modules:
            if args.fast_suite:
                submodule = '__fast_suite__'
            if args.sanity_checks:
                submodule = '__sanity_checks__'
            test_modules.extend(get_test_modules(module,
                submodule, explode=False))
    else:
        if submodule and args.fast_suite:
            print "Submodule name `%s` given, ignoring `--fast-suite`." % (submodule,)
        if submodule and args.sanity_checks:
            print "Submodule name `%s` given, ignoring `--sanity-checks`." % (submodule,)
        if not submodule and args.fast_suite:
            submodule = '__fast_suite__'
        if not submodule and args.sanity_checks:
            submodule = '__sanity_checks__'
        test_modules = get_test_modules(module,
            submodule, explode=True)

    # Run the test suite.
    if not args.dry_run:
        suite = unittest2.TestSuite()
        for test_module in test_modules:
            suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_module))
        r = unittest2.TextTestRunner(verbosity=2).run(suite)
        if r.errors or r.failures:
            sys.exit(1)
    else:
        print 'Test modules:'
        for test_module in test_modules:
            print ' ', test_module.__name__