Repository: pulp/pulpcore

Issue:
Deprecation warnings
```
  /usr/local/lib/python3.8/site-packages/dynaconf/contrib/django_dynaconf_v2.py:96: RemovedInDjango40Warning: The PASSWORD_RESET_TIMEOUT_DAYS setting is deprecated. Use PASSWORD_RESET_TIMEOUT instead.
```

```
   /usr/local/lib/python3.8/site-packages/dynaconf/utils/__init__.py:264: DeprecationWarning: You are using GLOBAL_ENV_FOR_DYNACONF which is a deprecated settings replace it with ENVVAR_PREFIX_FOR_DYNACONF
```

```
  /usr/local/lib/python3.8/site-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'pulpcore.app' defines default_app_config = 'pulpcore.app.apps.PulpAppConfig'. However, Django's automatic detection did not find this configuration. You should move the default config class to the apps submodule of your application and, if this module defines several config classes, mark the default one with default = True.
```

```
  /usr/local/lib/python3.8/site-packages/asynctest/mock.py:434: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
```

```
 usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetQuerySet::test_does_not_add_filters
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:43: RemovedInDjango41Warning: In Django 4.1, repr() will not be called automatically on a queryset when compared to string values. Set an explicit 'transform' to silence this warning.
```

```
 usr/local/lib/python3.8/site-packages/asynctest/helpers.py:13
  /usr/local/lib/python3.8/site-packages/asynctest/helpers.py:13: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def exhaust_callbacks(loop):

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_headers
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_user_agent_header
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_user_agent_header
  /usr/local/lib64/python3.8/site-packages/aiohttp/connector.py:771: DeprecationWarning: The object should be created within an async function
    super().__init__(

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_headers
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_user_agent_header
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_user_agent_header
  /usr/local/lib64/python3.8/site-packages/aiohttp/connector.py:782: DeprecationWarning: The object should be created within an async function
    resolver = DefaultResolver(loop=self._loop)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_headers
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_user_agent_header
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_user_agent_header
  /usr/local/lib/python3.8/site-packages/pulpcore/download/factory.py:145: DeprecationWarning: The object should be created within an async function
    return aiohttp.ClientSession(

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_headers
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_custom_user_agent_header
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/download/test_factory.py::DownloaderFactoryHeadersTestCase::test_user_agent_header
  /usr/local/lib64/python3.8/site-packages/aiohttp/cookiejar.py:67: DeprecationWarning: The object should be created within an async function
    super().__init__(loop=loop)
```

```
usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetSerializerClass::test_minimal_query_param
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:92: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetSerializerClass::test_minimal_query_param
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:96: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetSerializerClass::test_minimal_query_param
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:100: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(viewset.get_serializer_class(), serializers.MinimalTaskSerializer)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetSerializerClass::test_serializer_class
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:69: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetSerializerClass::test_serializer_class
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:75: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetParentFieldAndObject::test_get_parent_field_and_object
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:124: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(("repository", repo), viewset.get_parent_field_and_object())

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetParentFieldAndObject::test_get_parent_object
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:134: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(repo, viewset.get_parent_object())

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetNestDepth::test_get_nest_depth
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:142: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(1, viewsets.RepositoryViewSet._get_nest_depth())

usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py::TestGetNestDepth::test_get_nest_depth
  /usr/local/lib/python3.8/site-packages/pulpcore/tests/unit/viewsets/test_base.py:143: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(2, viewsets.RepositoryVersionViewSet._get_nest_depth())
```


Discussion:
Most of these are test related, but the first 3 are not, and the others ought to be addressed when we rewrite the tests.
@ggainey I think those are blockers just for 3.25.0 if I recall correctly. 

Resolving patch:
diff --git a/pulpcore/app/__init__.py b/pulpcore/app/__init__.py
--- a/pulpcore/app/__init__.py
+++ b/pulpcore/app/__init__.py
@@ -1 +0,0 @@
-default_app_config = "pulpcore.app.apps.PulpAppConfig"
diff --git a/pulpcore/app/apps.py b/pulpcore/app/apps.py
--- a/pulpcore/app/apps.py
+++ b/pulpcore/app/apps.py
@@ -227,6 +227,8 @@ class PulpAppConfig(PulpPluginAppConfig):
     # The app's importable name
     name = "pulpcore.app"
 
+    default = True
+
     # The app label to be used when creating tables, registering models, referencing this app
     # with manage.py, etc. This cannot contain a dot and must not conflict with the name of a
     # package containing a Django app.
diff --git a/pulpcore/app/settings.py b/pulpcore/app/settings.py
--- a/pulpcore/app/settings.py
+++ b/pulpcore/app/settings.py
@@ -365,7 +365,7 @@
 
 settings = DjangoDynaconf(
     __name__,
-    GLOBAL_ENV_FOR_DYNACONF="PULP",
+    ENVVAR_PREFIX_FOR_DYNACONF="PULP",
     ENV_SWITCHER_FOR_DYNACONF="PULP_ENV",
     PRELOAD_FOR_DYNACONF=[
         "{}.app.settings".format(plugin_name) for plugin_name in INSTALLED_PULP_PLUGINS


Test patch:
diff --git a/pulpcore/tests/unit/download/test_factory.py b/pulpcore/tests/unit/download/test_factory.py
--- a/pulpcore/tests/unit/download/test_factory.py
+++ b/pulpcore/tests/unit/download/test_factory.py
@@ -1,20 +1,21 @@
 from django.test import TestCase
+from asgiref.sync import sync_to_async
 
 from pulpcore.download.factory import DownloaderFactory
 from pulpcore.plugin.models import Remote
 
 
 class DownloaderFactoryHeadersTestCase(TestCase):
-    def test_user_agent_header(self):
-        remote = Remote.objects.create(url="http://example.org/", name="foo")
+    async def test_user_agent_header(self):
+        remote = await sync_to_async(Remote.objects.create)(url="http://example.org/", name="foo")
         factory = DownloaderFactory(remote)
         downloader = factory.build(remote.url)
         default_user_agent = DownloaderFactory.user_agent()
         self.assertEqual(downloader.session.headers["User-Agent"], default_user_agent)
-        remote.delete()
+        await sync_to_async(remote.delete)()
 
-    def test_custom_user_agent_header(self):
-        remote = Remote.objects.create(
+    async def test_custom_user_agent_header(self):
+        remote = await sync_to_async(Remote.objects.create)(
             url="http://example.org/", headers=[{"User-Agent": "foo"}], name="foo"
         )
         factory = DownloaderFactory(remote)
@@ -22,12 +23,13 @@ def test_custom_user_agent_header(self):
         default_user_agent = DownloaderFactory.user_agent()
         expected_user_agent = f"{default_user_agent}, foo"
         self.assertEqual(downloader.session.headers["User-Agent"], expected_user_agent)
-        remote.delete()
+        await sync_to_async(remote.delete)()
 
-    def test_custom_headers(self):
-        remote = Remote.objects.create(
+    async def test_custom_headers(self):
+        remote = await sync_to_async(Remote.objects.create)(
             url="http://example.org/", headers=[{"Connection": "keep-alive"}], name="foo"
         )
         factory = DownloaderFactory(remote)
         downloader = factory.build(remote.url)
         self.assertEqual(downloader.session.headers["Connection"], "keep-alive")
+        await sync_to_async(remote.delete)()
diff --git a/pulpcore/tests/unit/viewsets/test_base.py b/pulpcore/tests/unit/viewsets/test_base.py
--- a/pulpcore/tests/unit/viewsets/test_base.py
+++ b/pulpcore/tests/unit/viewsets/test_base.py
@@ -23,9 +23,7 @@ def test_adds_filters(self):
         queryset = viewset.get_queryset()
         expected = models.RepositoryVersion.objects.filter(repository__pk=repo.pk)
 
-        # weird, stupid django quirk
-        # https://docs.djangoproject.com/en/3.2/topics/testing/tools/#django.test.TransactionTestCase.assertQuerysetEqual
-        self.assertQuerysetEqual(queryset, map(repr, expected))
+        self.assertQuerysetEqual(queryset, expected)
 
     def test_does_not_add_filters(self):
         """
@@ -38,9 +36,7 @@ def test_does_not_add_filters(self):
         queryset = viewset.get_queryset()
         expected = models.Repository.objects.all()
 
-        # weird, stupid django quirk
-        # https://docs.djangoproject.com/en/3.2/topics/testing/tools/#django.test.TransactionTestCase.assertQuerysetEqual
-        self.assertQuerysetEqual(queryset, map(repr, expected))
+        self.assertQuerysetEqual(queryset, expected)
 
 
 class TestGetSerializerClass(TestCase):
@@ -66,13 +62,13 @@ class TestTaskViewSet(viewsets.NamedModelViewSet):
             serializer_class = serializers.TaskSerializer
 
         viewset = TestTaskViewSet()
-        self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)
+        self.assertEqual(viewset.get_serializer_class(), serializers.TaskSerializer)
 
         request = unittest.mock.MagicMock()
         request.query_params = QueryDict("minimal=True")
         viewset.request = request
 
-        self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)
+        self.assertEqual(viewset.get_serializer_class(), serializers.TaskSerializer)
 
     def test_minimal_query_param(self):
         """
@@ -89,15 +85,15 @@ class TestTaskViewSet(viewsets.NamedModelViewSet):
         # Test that it uses the full serializer with no query params
         request.query_params = QueryDict()
         viewset.request = request
-        self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)
+        self.assertEqual(viewset.get_serializer_class(), serializers.TaskSerializer)
         # Test that it uses the full serializer with minimal=False
         request.query_params = QueryDict("minimal=False")
         viewset.request = request
-        self.assertEquals(viewset.get_serializer_class(), serializers.TaskSerializer)
+        self.assertEqual(viewset.get_serializer_class(), serializers.TaskSerializer)
         # Test that it uses the minimal serializer with minimal=True
         request.query_params = QueryDict("minimal=True")
         viewset.request = request
-        self.assertEquals(viewset.get_serializer_class(), serializers.MinimalTaskSerializer)
+        self.assertEqual(viewset.get_serializer_class(), serializers.MinimalTaskSerializer)
 
 
 class TestGetParentFieldAndObject(TestCase):
@@ -121,7 +117,7 @@ def test_get_parent_field_and_object(self):
         viewset = viewsets.RepositoryVersionViewSet()
         viewset.kwargs = {"repository_pk": repo.pk}
 
-        self.assertEquals(("repository", repo), viewset.get_parent_field_and_object())
+        self.assertEqual(("repository", repo), viewset.get_parent_field_and_object())
 
     def test_get_parent_object(self):
         """
@@ -131,7 +127,7 @@ def test_get_parent_object(self):
         viewset = viewsets.RepositoryVersionViewSet()
         viewset.kwargs = {"repository_pk": repo.pk}
 
-        self.assertEquals(repo, viewset.get_parent_object())
+        self.assertEqual(repo, viewset.get_parent_object())
 
 
 class TestGetNestDepth(TestCase):
@@ -139,5 +135,5 @@ def test_get_nest_depth(self):
         """
         Test that _get_nest_depth() returns the correct nesting depths.
         """
-        self.assertEquals(1, viewsets.RepositoryViewSet._get_nest_depth())
-        self.assertEquals(2, viewsets.RepositoryVersionViewSet._get_nest_depth())
+        self.assertEqual(1, viewsets.RepositoryViewSet._get_nest_depth())
+        self.assertEqual(2, viewsets.RepositoryVersionViewSet._get_nest_depth())