# Path: django_performance_testing/registry.py
# 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)
# 
# class DuplicateNamesError(TypeError):
#     pass


from django_performance_testing.registry import \
    UniqueNamedClassRegistry, DuplicateNamesError
from testapp.registry_entries_one import LimitOne as L1
from testapp.registry_entries_two import LimitTwo as L2
import pytest


limit_one = 'testapp.registry_entries_one.LimitOne'
limit_two = 'testapp.registry_entries_two.LimitTwo'


@pytest.mark.parametrize(
    'dotted_paths,expected_names,expected_classes', [
        ([], [], []),
        ([limit_one, limit_two], ['LimitOne', 'LimitTwo'], [L1,  L2]),
        ([limit_two, limit_one], ['LimitTwo', 'LimitOne'], [L2, L1]),
    ], ids=[
        'empty', 'one-two', 'two-one'
    ]
)
def test_registry_building_happy_path(
        dotted_paths, expected_names, expected_classes):

# Path: django_performance_testing/registry.py
# 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)
# 
# class DuplicateNamesError(TypeError):
#     pass


# Path: tests/testapp/tests/test_core_constructing_a_registry.py
from django_performance_testing.registry import \
    UniqueNamedClassRegistry, DuplicateNamesError
from testapp.registry_entries_one import LimitOne as L1
from testapp.registry_entries_two import LimitTwo as L2
import pytest



limit_one = 'testapp.registry_entries_one.LimitOne'
limit_two = 'testapp.registry_entries_two.LimitTwo'


@pytest.mark.parametrize(
    'dotted_paths,expected_names,expected_classes', [
        ([], [], []),
        ([limit_one, limit_two], ['LimitOne', 'LimitTwo'], [L1,  L2]),
        ([limit_two, limit_one], ['LimitTwo', 'LimitOne'], [L2, L1]),
    ], ids=[
        'empty', 'one-two', 'two-one'
    ]
)
def test_registry_building_happy_path(
        dotted_paths, expected_names, expected_classes):

    registry = UniqueNamedClassRegistry(dotted_paths)