# Path: modernrpc/apps.py
# @checks.register()
# def check_settings(app_configs, **kwargs):
#     """Perform common checks on lib configuration, to notify for warning and errors. Uses
#     Django "System check framework": see https://docs.djangoproject.com/en/3.2/topics/checks/"""
#     messages = []
# 
#     if not settings.MODERNRPC_METHODS_MODULES:
#         msg = "settings.MODERNRPC_METHODS_MODULES is not set, django-modern-rpc cannot locate your RPC methods."
#         # TODO: put link to correct docs target page here
#         hint = (
#             "Please define MODERNRPC_METHODS_MODULES in your settings.py to indicate modules containing your "
#             "methods. See documentation for more info"
#         )
#         messages.append(
#             checks.Warning(msg, hint=hint, obj=settings, id="modernrpc.W001")
#         )
# 
#     else:
#         for module_name in settings.MODERNRPC_METHODS_MODULES:
#             try:
#                 import_module(module_name)
#             except ImportError as err:
#                 # ModuleNotFoundError may be caught here, when library will require python 3.6+
#                 msg = 'ModuleNotFoundError exception when importing "{}" module'.format(
#                     module_name
#                 )
#                 hint = str(err)
#                 messages.append(
#                     checks.Error(msg, hint=hint, obj=settings, id="modernrpc.E001")
#                 )
#             except Exception as exc:
#                 msg = '{} exception when importing "{}" module'.format(
#                     exc.__class__.__name__, module_name
#                 )
#                 hint = "See exception info: {}".format(exc)
#                 messages.append(
#                     checks.Error(msg, hint=hint, obj=settings, id="modernrpc.E002")
#                 )
# 
#     return messages
# 
# Path: modernrpc/core.py
# ALL = GENERIC_ALL
# 
# Path: tests/unit/stubs.py
# @rpc_method
# def dummy_remote_procedure_1():
#     # Manually registered remote procedure.
#     return 33
# 
# @rpc_method(name="another_name")
# def dummy_remote_procedure_2():
#     # Manually registered remote procedure, with custom name.
#     return 33
# 
# @rpc_method(name="rpc.invalid.name")
# def dummy_remote_procedure_3():
#     # Manually registered remote procedure, with invalid custom name.
#     return 42
# 
# @rpc_method(name="divide")
# def dummy_remote_procedure_4():
#     # Manually registered remote procedure, with invalid custom name (name already registered).
#     return 42
# 
# def not_decorated_procedure():
#     pass


import pytest
import modernrpc
from django.apps.registry import apps
from django.core.exceptions import ImproperlyConfigured
from modernrpc.apps import check_settings
from modernrpc.core import ALL
from tests.unit.stubs import (
    dummy_remote_procedure_1,
    dummy_remote_procedure_2,
    dummy_remote_procedure_3,
    dummy_remote_procedure_4,
    not_decorated_procedure,
)
        sorted_list = rpc_registry.get_all_method_names(sort_methods=True)

        assert len(raw_list) == len(sorted_list)
        assert raw_list != sorted_list

        for n in raw_list:
            assert n in sorted_list
        for n in sorted_list:
            assert n in raw_list

    def test_methods_list(self, rpc_registry):
        raw_list = rpc_registry.get_all_methods()
        sorted_list = rpc_registry.get_all_methods(sort_methods=True)

        assert len(raw_list) == len(sorted_list)
        assert raw_list != sorted_list

        for m in raw_list:
            assert m in sorted_list

        for m in sorted_list:
            assert m in raw_list

    # Tests for backward compatibility
    def test_backward_compat_register_method(self, rpc_registry):
        assert "dummy_remote_procedure_1" not in modernrpc.core.get_all_method_names()
        modernrpc.core.register_rpc_method(dummy_remote_procedure_1)
        assert "dummy_remote_procedure_1" in modernrpc.core.get_all_method_names()

    def test_backward_compat_registry(self, rpc_registry):

# Path: modernrpc/apps.py
# @checks.register()
# def check_settings(app_configs, **kwargs):
#     """Perform common checks on lib configuration, to notify for warning and errors. Uses
#     Django "System check framework": see https://docs.djangoproject.com/en/3.2/topics/checks/"""
#     messages = []
# 
#     if not settings.MODERNRPC_METHODS_MODULES:
#         msg = "settings.MODERNRPC_METHODS_MODULES is not set, django-modern-rpc cannot locate your RPC methods."
#         # TODO: put link to correct docs target page here
#         hint = (
#             "Please define MODERNRPC_METHODS_MODULES in your settings.py to indicate modules containing your "
#             "methods. See documentation for more info"
#         )
#         messages.append(
#             checks.Warning(msg, hint=hint, obj=settings, id="modernrpc.W001")
#         )
# 
#     else:
#         for module_name in settings.MODERNRPC_METHODS_MODULES:
#             try:
#                 import_module(module_name)
#             except ImportError as err:
#                 # ModuleNotFoundError may be caught here, when library will require python 3.6+
#                 msg = 'ModuleNotFoundError exception when importing "{}" module'.format(
#                     module_name
#                 )
#                 hint = str(err)
#                 messages.append(
#                     checks.Error(msg, hint=hint, obj=settings, id="modernrpc.E001")
#                 )
#             except Exception as exc:
#                 msg = '{} exception when importing "{}" module'.format(
#                     exc.__class__.__name__, module_name
#                 )
#                 hint = "See exception info: {}".format(exc)
#                 messages.append(
#                     checks.Error(msg, hint=hint, obj=settings, id="modernrpc.E002")
#                 )
# 
#     return messages
# 
# Path: modernrpc/core.py
# ALL = GENERIC_ALL
# 
# Path: tests/unit/stubs.py
# @rpc_method
# def dummy_remote_procedure_1():
#     # Manually registered remote procedure.
#     return 33
# 
# @rpc_method(name="another_name")
# def dummy_remote_procedure_2():
#     # Manually registered remote procedure, with custom name.
#     return 33
# 
# @rpc_method(name="rpc.invalid.name")
# def dummy_remote_procedure_3():
#     # Manually registered remote procedure, with invalid custom name.
#     return 42
# 
# @rpc_method(name="divide")
# def dummy_remote_procedure_4():
#     # Manually registered remote procedure, with invalid custom name (name already registered).
#     return 42
# 
# def not_decorated_procedure():
#     pass


# Path: tests/unit/test_initialization.py
import pytest
import modernrpc
from django.apps.registry import apps
from django.core.exceptions import ImproperlyConfigured
from modernrpc.apps import check_settings
from modernrpc.core import ALL
from tests.unit.stubs import (
    dummy_remote_procedure_1,
    dummy_remote_procedure_2,
    dummy_remote_procedure_3,
    dummy_remote_procedure_4,
    not_decorated_procedure,
)

        sorted_list = rpc_registry.get_all_method_names(sort_methods=True)

        assert len(raw_list) == len(sorted_list)
        assert raw_list != sorted_list

        for n in raw_list:
            assert n in sorted_list
        for n in sorted_list:
            assert n in raw_list

    def test_methods_list(self, rpc_registry):
        raw_list = rpc_registry.get_all_methods()
        sorted_list = rpc_registry.get_all_methods(sort_methods=True)

        assert len(raw_list) == len(sorted_list)
        assert raw_list != sorted_list

        for m in raw_list:
            assert m in sorted_list

        for m in sorted_list:
            assert m in raw_list

    # Tests for backward compatibility
    def test_backward_compat_register_method(self, rpc_registry):
        assert "dummy_remote_procedure_1" not in modernrpc.core.get_all_method_names()
        modernrpc.core.register_rpc_method(dummy_remote_procedure_1)
        assert "dummy_remote_procedure_1" in modernrpc.core.get_all_method_names()

    def test_backward_compat_registry(self, rpc_registry):

        assert rpc_registry.get_method("divide", ALL, ALL) == modernrpc.core.get_method(