kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Fix #648: Improved test suite speed by reducing / disabling expensive operations
rodzic
17cb09fdc6
commit
7657db4212
|
@ -592,3 +592,7 @@ VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
|
|||
]
|
||||
}
|
||||
VERSATILEIMAGEFIELD_SETTINGS = {"create_images_on_demand": False}
|
||||
RSA_KEY_SIZE = 2048
|
||||
# for performance gain in tests, since we don't need to actually create the
|
||||
# thumbnails
|
||||
CREATE_IMAGE_THUMBNAILS = env.bool("CREATE_IMAGE_THUMBNAILS", default=True)
|
||||
|
|
|
@ -31,7 +31,6 @@ EMAIL_PORT = 1025
|
|||
|
||||
# django-debug-toolbar
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE += ("debug_toolbar.middleware.DebugToolbarMiddleware",)
|
||||
|
||||
# INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',)
|
||||
|
||||
|
@ -45,14 +44,18 @@ DEBUG_TOOLBAR_CONFIG = {
|
|||
# django-extensions
|
||||
# ------------------------------------------------------------------------------
|
||||
# INSTALLED_APPS += ('django_extensions', )
|
||||
INSTALLED_APPS += ("debug_toolbar",)
|
||||
|
||||
# Debug toolbar is slow, we disable it for tests
|
||||
DEBUG_TOOLBAR_ENABLED = env.bool("DEBUG_TOOLBAR_ENABLED", default=DEBUG)
|
||||
if DEBUG_TOOLBAR_ENABLED:
|
||||
MIDDLEWARE += ("debug_toolbar.middleware.DebugToolbarMiddleware",)
|
||||
INSTALLED_APPS += ("debug_toolbar",)
|
||||
|
||||
# TESTING
|
||||
# ------------------------------------------------------------------------------
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
|
||||
# CELERY
|
||||
# In development, all tasks will be executed locally by blocking until the task returns
|
||||
CELERY_TASK_ALWAYS_EAGER = False
|
||||
# END CELERY
|
||||
|
||||
|
@ -72,3 +75,8 @@ LOGGING = {
|
|||
},
|
||||
}
|
||||
CSRF_TRUSTED_ORIGINS = [o for o in ALLOWED_HOSTS]
|
||||
|
||||
|
||||
if env.bool("WEAK_PASSWORDS", default=False):
|
||||
# Faster during tests
|
||||
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import re
|
||||
import urllib.parse
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from cryptography.hazmat.backends import default_backend as crypto_default_backend
|
||||
from cryptography.hazmat.primitives import serialization as crypto_serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
|
@ -8,7 +10,8 @@ from cryptography.hazmat.primitives.asymmetric import rsa
|
|||
KEY_ID_REGEX = re.compile(r"keyId=\"(?P<id>.*)\"")
|
||||
|
||||
|
||||
def get_key_pair(size=2048):
|
||||
def get_key_pair(size=None):
|
||||
size = size or settings.RSA_KEY_SIZE
|
||||
key = rsa.generate_private_key(
|
||||
backend=crypto_default_backend(), public_exponent=65537, key_size=size
|
||||
)
|
||||
|
|
|
@ -1107,7 +1107,7 @@ def update_request_status(sender, instance, created, **kwargs):
|
|||
|
||||
@receiver(models.signals.post_save, sender=Album)
|
||||
def warm_album_covers(sender, instance, **kwargs):
|
||||
if not instance.cover:
|
||||
if not instance.cover or not settings.CREATE_IMAGE_THUMBNAILS:
|
||||
return
|
||||
album_covers_warmer = VersatileImageFieldWarmer(
|
||||
instance_or_queryset=instance, rendition_key_set="square", image_attr="cover"
|
||||
|
|
|
@ -295,7 +295,7 @@ def init_ldap_user(sender, user, ldap_user, **kwargs):
|
|||
|
||||
@receiver(models.signals.post_save, sender=User)
|
||||
def warm_user_avatar(sender, instance, **kwargs):
|
||||
if not instance.avatar:
|
||||
if not instance.avatar or not settings.CREATE_IMAGE_THUMBNAILS:
|
||||
return
|
||||
user_avatar_warmer = VersatileImageFieldWarmer(
|
||||
instance_or_queryset=instance, rendition_key_set="square", image_attr="avatar"
|
||||
|
|
|
@ -19,3 +19,7 @@ env =
|
|||
CELERY_BROKER_URL=memory://
|
||||
CELERY_TASK_ALWAYS_EAGER=True
|
||||
FEDERATION_HOSTNAME=test.federation
|
||||
DEBUG_TOOLBAR_ENABLED=False
|
||||
DEBUG=False
|
||||
WEAK_PASSWORDS=True
|
||||
CREATE_IMAGE_THUMBNAILS=False
|
||||
|
|
|
@ -410,3 +410,9 @@ def no_api_auth(preferences):
|
|||
def migrator(transactional_db):
|
||||
yield MigrationExecutor(connection)
|
||||
call_command("migrate", interactive=False)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def rsa_small_key(settings):
|
||||
# smaller size for faster generation, since it's CPU hungry
|
||||
settings.RSA_KEY_SIZE = 512
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Improved test suite speed by reducing / disabling expensive operations (#648)
|
Ładowanie…
Reference in New Issue