mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
tests: disable db logger in all tests except logger tests
This commit is contained in:
parent
20c1139632
commit
35b2033949
@ -1,9 +1,14 @@
|
|||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class PaperlessHandler(logging.Handler):
|
class PaperlessHandler(logging.Handler):
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
|
if settings.DISABLE_DBHANDLER:
|
||||||
|
return
|
||||||
|
|
||||||
# We have to do the import here or Django will barf when it tries to
|
# We have to do the import here or Django will barf when it tries to
|
||||||
# load this because the apps aren't loaded at that point
|
# load this because the apps aren't loaded at that point
|
||||||
from .models import Log
|
from .models import Log
|
||||||
|
@ -2,7 +2,7 @@ import logging
|
|||||||
import uuid
|
import uuid
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase, override_settings
|
||||||
|
|
||||||
from ..models import Log
|
from ..models import Log
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ class TestPaperlessLog(TestCase):
|
|||||||
self.logger = logging.getLogger(
|
self.logger = logging.getLogger(
|
||||||
"documents.management.commands.document_consumer")
|
"documents.management.commands.document_consumer")
|
||||||
|
|
||||||
|
@override_settings(DISABLE_DBHANDLER=False)
|
||||||
def test_that_it_saves_at_all(self):
|
def test_that_it_saves_at_all(self):
|
||||||
|
|
||||||
kw = {"group": uuid.uuid4()}
|
kw = {"group": uuid.uuid4()}
|
||||||
@ -38,6 +39,7 @@ class TestPaperlessLog(TestCase):
|
|||||||
self.logger.critical("This is a critical message", extra=kw)
|
self.logger.critical("This is a critical message", extra=kw)
|
||||||
self.assertEqual(Log.objects.all().count(), 5)
|
self.assertEqual(Log.objects.all().count(), 5)
|
||||||
|
|
||||||
|
@override_settings(DISABLE_DBHANDLER=False)
|
||||||
def test_groups(self):
|
def test_groups(self):
|
||||||
|
|
||||||
kw1 = {"group": uuid.uuid4()}
|
kw1 = {"group": uuid.uuid4()}
|
||||||
|
@ -250,6 +250,8 @@ USE_TZ = True
|
|||||||
# Logging #
|
# Logging #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
DISABLE_DBHANDLER = __get_boolean("PAPERLESS_DISABLE_DBHANDLER")
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"disable_existing_loggers": False,
|
"disable_existing_loggers": False,
|
||||||
|
@ -5,8 +5,7 @@ exclude = migrations, paperless/settings.py, .tox, */tests/*
|
|||||||
DJANGO_SETTINGS_MODULE=paperless.settings
|
DJANGO_SETTINGS_MODULE=paperless.settings
|
||||||
addopts = --pythonwarnings=all --cov --cov-report=html
|
addopts = --pythonwarnings=all --cov --cov-report=html
|
||||||
env =
|
env =
|
||||||
PAPERLESS_SECRET=paperless
|
PAPERLESS_DISABLE_DBHANDLER=true
|
||||||
PAPERLESS_EMAIL_SECRET=paperless
|
|
||||||
|
|
||||||
|
|
||||||
[coverage:run]
|
[coverage:run]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user