from unittest import TestCase


class AppUtilsTests(TestCase):
    def test_get_module_for_app(self):
        from django.apps import apps

        config = apps.get_app_config('djadmin')

        same = [
            'test_app',
            'admin_app.plugins.admin_app_plugin',
        ]

        for item in same:
            self.assertEqual(
                config._get_module_for_app(item),
                item,
            )

        different = {
            'other_app.apps.AppConfig': 'other_app',
            'reversion_compare.apps.AppConfig': 'reversion_compare',
        }

        for item, expected in different.items():
            self.assertEqual(
                config._get_module_for_app(item),
                expected,
            )
