示例#1
0
            doc_id = row['id']
            if doc_id not in deleted:
                try:
                    safe_delete(db, doc_id)
                    deleted.add(doc_id)
                except ResourceNotFound:
                    pass


run_with_all_backends = functools.partial(
    run_with_multiple_configs,
    run_configs=[
        # run with default setting
        RunConfig(
            settings={
                'TESTS_SHOULD_USE_SQL_BACKEND': getattr(settings, 'TESTS_SHOULD_USE_SQL_BACKEND', False),
            },
            post_run=lambda *args, **kwargs: args[0].tearDown()
        ),
        # run with inverse of default setting
        RunConfig(
            settings={
                'TESTS_SHOULD_USE_SQL_BACKEND': not getattr(settings, 'TESTS_SHOULD_USE_SQL_BACKEND', False),
            },
            pre_run=lambda *args, **kwargs: args[0].setUp(),
        ),
    ],
    nose_tags={'all_backends': True}
)


def partitioned(cls):
示例#2
0
    return DomainLite(name, None, None, True)


def post_run_with_sql_backend(fn, *args, **kwargs):
    fn.doCleanups()
    fn.tearDown()


def pre_run_with_es_backend(fn, *args, **kwargs):
    fn.setUp()


run_with_all_ucr_backends = functools.partial(
    run_with_multiple_configs,
    run_configs=[
        RunConfig(settings={'OVERRIDE_UCR_BACKEND': UCR_SQL_BACKEND},
                  post_run=post_run_with_sql_backend),
        RunConfig(
            settings={'OVERRIDE_UCR_BACKEND': UCR_ES_BACKEND},
            pre_run=pre_run_with_es_backend,
        ),
    ])


def mock_sql_backend():
    return patch('corehq.apps.userreports.reports.data_source.get_backend_id',
                 return_value=UCR_SQL_BACKEND)


def mock_datasource_config():
    return patch(
        'corehq.apps.userreports.reports.data_source.get_datasource_config',
示例#3
0
import functools
from corehq.util.test_utils import run_with_multiple_configs, RunConfig

run_pre_and_post_timezone_migration = functools.partial(
    run_with_multiple_configs,
    run_configs=[
        RunConfig(settings={
            'PHONE_TIMEZONES_SHOULD_BE_PROCESSED': True,
            'PHONE_TIMEZONES_HAVE_BEEN_PROCESSED': True,
        }, ),
        RunConfig(settings={
            'PHONE_TIMEZONES_SHOULD_BE_PROCESSED': False,
            'PHONE_TIMEZONES_HAVE_BEEN_PROCESSED': False,
        }, )
    ])
示例#4
0
    return DomainLite(name, None, None, True)


def post_run_with_sql_backend(fn, *args, **kwargs):
    fn.doCleanups()
    fn.tearDown()


def pre_run_with_es_backend(fn, *args, **kwargs):
    fn.setUp()


run_with_all_ucr_backends = functools.partial(
    run_with_multiple_configs,
    run_configs=[
        RunConfig(settings={'OVERRIDE_UCR_BACKEND': "SQL"},
                  post_run=post_run_with_sql_backend),
        RunConfig(
            settings={'OVERRIDE_UCR_BACKEND': "ES"},
            pre_run=pre_run_with_es_backend,
        ),
    ])


def mock_sql_backend():
    return patch('corehq.apps.userreports.reports.data_source.get_backend_id',
                 return_value=UCR_SQL_BACKEND)


def mock_datasource_config():
    return patch(
        'corehq.apps.userreports.reports.data_source.get_datasource_config',