Skip to content

Commit

Permalink
Merge pull request #495 from jazzband/daadu-patch-1
Browse files Browse the repository at this point in the history
`apps.py` added with `default_auto_field` set
  • Loading branch information
daadu committed Sep 25, 2021
2 parents 038271c + bf548fd commit 66a66ec
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
14 changes: 14 additions & 0 deletions project/tests/test_app_config.py
@@ -0,0 +1,14 @@
from django.apps import apps as proj_apps
from django.test import TestCase

from silk.apps import SilkAppConfig


class TestAppConfig(TestCase):
"""
Test if correct AppConfig class is loaded by Django.
"""

def test_app_config_loaded(self):
silk_app_config = proj_apps.get_app_config("silk")
self.assertIsInstance(silk_app_config, SilkAppConfig)
22 changes: 21 additions & 1 deletion project/tests/test_models.py
Expand Up @@ -3,7 +3,8 @@
import uuid
import pytz

from django.test import TestCase
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.utils import timezone


Expand Down Expand Up @@ -491,6 +492,25 @@ def test_delete_if_has_request(self):
self.assertNotIn(self.obj, models.SQLQuery.objects.all())


class NoPendingMigrationsTest(TestCase):
"""
Test if proper migrations are added and the models state is consistent.
It should make sure that no new migrations are created for this app,
when end-user runs `makemigrations` command.
"""

def test_no_pending_migrations(self):
call_command("makemigrations", "silk", "--check", "--dry-run")

@override_settings(DEFAULT_AUTO_FIELD='django.db.models.BigAutoField')
def test_check_with_overridden_default_auto_field(self):
"""
Test with `BigAutoField` set as `DEFAULT_AUTO_FIELD` - which is
default when generating proj with Django 3.2.
"""
self.test_no_pending_migrations()


class BaseProfileTest(TestCase):
pass

Expand Down
3 changes: 3 additions & 0 deletions silk/__init__.py
Expand Up @@ -4,3 +4,6 @@
__version__ = get_distribution("django-silk").version
except DistributionNotFound:
pass

# set default_app_config
default_app_config = 'silk.apps.SilkAppConfig'
5 changes: 5 additions & 0 deletions silk/apps.py
@@ -0,0 +1,5 @@
from django.apps import AppConfig

class SilkAppConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'silk'

0 comments on commit 66a66ec

Please sign in to comment.