# Path: django_performance_testing/core.py
# class NameValueResult(object):
# class LimitViolationError(RuntimeError):
# class BaseCollector(object):
# class BaseLimit(object):
#     def __init__(self, name, value):
#     def _to_cmp_val(self, other):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __str__(self):
#     def __init__(self, limit_obj, result, context, tb=None):
#     def error_msg(self):
#     def tb_msg(self):
#     def context_repr(self):
#     def base_error_msg(self):
#     def quantifier(self):
#     def items_name(self):
#     def name(self):
#     def collector_text(self):
#     def actual(self):
#     def limit(self):
#     def clone_with_more_info(self, orig_tb):
#     def __init__(self, id_=None):
#     def should_have_unique_id(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def get_results_to_send(self):
#     def before_exit(self):
#     def __init__(self, collector_id=None, settings_based=False, **data):
#     def _validate_data(self):
#     def data(self):
#     def type_name(self):
#     def __enter__(self):
#     def connect_for_results(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def is_anonymous(self):
#     def results_collected_handler(
#             self, signal, sender, results, context, **kwargs):
#     def handle_results(self, results, context):
#     def handle_result(self, result, context):
#     def limit_for(self, result):
# 
# Path: django_performance_testing/queries.py
# class QueryBatchLimit(BaseLimit):
#     collector_cls = QueryCollector
# 
#     quantifier = 'many'
#     items_name = 'queries'
# 
# Path: django_performance_testing/registry.py
# class SettingsOrDefaultBasedRegistry(UniqueNamedClassRegistry):
# 
#     settings_name = 'DJPT_KNOWN_LIMITS_DOTTED_PATHS'
# 
#     defaults = (
#         'django_performance_testing.queries.QueryBatchLimit',
#         'django_performance_testing.timing.TimeLimit',
#     )
# 
#     def __init__(self):
#         super(SettingsOrDefaultBasedRegistry, self).__init__(
#             self.dotted_paths_for_init)
# 
#     @property
#     def dotted_paths_for_init(self):
#         if not hasattr(settings, self.settings_name):
#             return self.defaults
#         return getattr(settings, self.settings_name)
# 
# class UniqueNamedClassRegistry(object):
#     def __init__(self, dotted_paths):
#         self._build_name2cls(dotted_paths)
# 
#     def _build_name2cls(self, dotted_paths):
#         self.name2cls = OrderedDict(
#             (cls.__name__, cls)
#             for cls in six.moves.map(self._to_cls, dotted_paths)
#         )
#         if len(self.name2cls) != len(dotted_paths):
#             raise DuplicateNamesError()
# 
#     def _to_cls(self, dotted_path):
#         return import_string(dotted_path)
# 
# Path: django_performance_testing/timing.py
# class TimeLimit(BaseLimit):
#     collector_cls = TimeCollector
# 
#     quantifier = 'many'
#     items_name = 'elapsed seconds'


from django_performance_testing import core
from django_performance_testing.queries import QueryBatchLimit
from django_performance_testing.registry import \
    SettingsOrDefaultBasedRegistry, UniqueNamedClassRegistry
from django_performance_testing.timing import TimeLimit
from testapp.sixmock import patch
        default_from_args, vals)
    assert vals == default_from_args.dotted_paths_for_init


def test_when_no_settings_specified_defaults_are_used(settings):
    """
        'dupicate' of test_sanity_check_test_double as code goes,
        but not by intent, hence the separate test
    """
    assert not hasattr(settings, SODBRToTest.settings_name)
    vals = ('asd', '2asd')
    assert SODBRToTest(vals).dotted_paths_for_init == vals


def test_when_settings_exist_that_is_taken_and_default_is_ignored(settings):
    settings.DJPT_DOTTED_PATHS_FOR_TESTING = ('asd',)
    defaults = ('qwert',)
    assert settings.DJPT_DOTTED_PATHS_FOR_TESTING != defaults  # sanity check
    sut = SODBRToTest(defaults=defaults)
    assert sut.dotted_paths_for_init == settings.DJPT_DOTTED_PATHS_FOR_TESTING


def test_assert_configured_global_limits_registry(settings):
    assert isinstance(core.limits_registry, SettingsOrDefaultBasedRegistry)
    assert core.limits_registry.settings_name == \
        'DJPT_KNOWN_LIMITS_DOTTED_PATHS'
    assert not hasattr(settings, core.limits_registry.settings_name)
    assert len(core.limits_registry.name2cls) == 2
    assert len(core.limits_registry.defaults) == 2
    assert core.limits_registry.name2cls['QueryBatchLimit'] == QueryBatchLimit

# Path: django_performance_testing/core.py
# class NameValueResult(object):
# class LimitViolationError(RuntimeError):
# class BaseCollector(object):
# class BaseLimit(object):
#     def __init__(self, name, value):
#     def _to_cmp_val(self, other):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __str__(self):
#     def __init__(self, limit_obj, result, context, tb=None):
#     def error_msg(self):
#     def tb_msg(self):
#     def context_repr(self):
#     def base_error_msg(self):
#     def quantifier(self):
#     def items_name(self):
#     def name(self):
#     def collector_text(self):
#     def actual(self):
#     def limit(self):
#     def clone_with_more_info(self, orig_tb):
#     def __init__(self, id_=None):
#     def should_have_unique_id(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def get_results_to_send(self):
#     def before_exit(self):
#     def __init__(self, collector_id=None, settings_based=False, **data):
#     def _validate_data(self):
#     def data(self):
#     def type_name(self):
#     def __enter__(self):
#     def connect_for_results(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def is_anonymous(self):
#     def results_collected_handler(
#             self, signal, sender, results, context, **kwargs):
#     def handle_results(self, results, context):
#     def handle_result(self, result, context):
#     def limit_for(self, result):
# 
# Path: django_performance_testing/queries.py
# class QueryBatchLimit(BaseLimit):
#     collector_cls = QueryCollector
# 
#     quantifier = 'many'
#     items_name = 'queries'
# 
# Path: django_performance_testing/registry.py
# class SettingsOrDefaultBasedRegistry(UniqueNamedClassRegistry):
# 
#     settings_name = 'DJPT_KNOWN_LIMITS_DOTTED_PATHS'
# 
#     defaults = (
#         'django_performance_testing.queries.QueryBatchLimit',
#         'django_performance_testing.timing.TimeLimit',
#     )
# 
#     def __init__(self):
#         super(SettingsOrDefaultBasedRegistry, self).__init__(
#             self.dotted_paths_for_init)
# 
#     @property
#     def dotted_paths_for_init(self):
#         if not hasattr(settings, self.settings_name):
#             return self.defaults
#         return getattr(settings, self.settings_name)
# 
# class UniqueNamedClassRegistry(object):
#     def __init__(self, dotted_paths):
#         self._build_name2cls(dotted_paths)
# 
#     def _build_name2cls(self, dotted_paths):
#         self.name2cls = OrderedDict(
#             (cls.__name__, cls)
#             for cls in six.moves.map(self._to_cls, dotted_paths)
#         )
#         if len(self.name2cls) != len(dotted_paths):
#             raise DuplicateNamesError()
# 
#     def _to_cls(self, dotted_path):
#         return import_string(dotted_path)
# 
# Path: django_performance_testing/timing.py
# class TimeLimit(BaseLimit):
#     collector_cls = TimeCollector
# 
#     quantifier = 'many'
#     items_name = 'elapsed seconds'


# Path: tests/testapp/tests/test_core_settings_based_registry.py
from django_performance_testing import core
from django_performance_testing.queries import QueryBatchLimit
from django_performance_testing.registry import \
    SettingsOrDefaultBasedRegistry, UniqueNamedClassRegistry
from django_performance_testing.timing import TimeLimit
from testapp.sixmock import patch

        default_from_args, vals)
    assert vals == default_from_args.dotted_paths_for_init


def test_when_no_settings_specified_defaults_are_used(settings):
    """
        'dupicate' of test_sanity_check_test_double as code goes,
        but not by intent, hence the separate test
    """
    assert not hasattr(settings, SODBRToTest.settings_name)
    vals = ('asd', '2asd')
    assert SODBRToTest(vals).dotted_paths_for_init == vals


def test_when_settings_exist_that_is_taken_and_default_is_ignored(settings):
    settings.DJPT_DOTTED_PATHS_FOR_TESTING = ('asd',)
    defaults = ('qwert',)
    assert settings.DJPT_DOTTED_PATHS_FOR_TESTING != defaults  # sanity check
    sut = SODBRToTest(defaults=defaults)
    assert sut.dotted_paths_for_init == settings.DJPT_DOTTED_PATHS_FOR_TESTING


def test_assert_configured_global_limits_registry(settings):
    assert isinstance(core.limits_registry, SettingsOrDefaultBasedRegistry)
    assert core.limits_registry.settings_name == \
        'DJPT_KNOWN_LIMITS_DOTTED_PATHS'
    assert not hasattr(settings, core.limits_registry.settings_name)
    assert len(core.limits_registry.name2cls) == 2
    assert len(core.limits_registry.defaults) == 2
    assert core.limits_registry.name2cls['QueryBatchLimit'] == QueryBatchLimit

    assert core.limits_registry.name2cls['TimeLimit'] == TimeLimit