Add SilenceLoggerTestCaseMixin
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
* Update Pillow to version 6.0.0
|
||||
* Update PyYAML to version 5.1. Update use of safe_load and
|
||||
safe_dump to load and dump using the SafeLoader.
|
||||
* Add SilenceLoggerTestCaseMixin to lower level of loggers
|
||||
during tests.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
|
||||
@@ -50,6 +50,8 @@ Other changes
|
||||
to the API app's URLs module.
|
||||
* Update PyYAML to version 5.1. Update use of safe_load and
|
||||
safe_dump to load and dump using the CSafeLoader and SafeLoader as fallback.
|
||||
* Add SilenceLoggerTestCaseMixin to lower level of loggers
|
||||
during tests.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -12,12 +12,12 @@ from mayan.apps.user_management.tests.mixins import UserTestCaseMixin
|
||||
from .mixins import (
|
||||
ClientMethodsTestCaseMixin, ContentTypeCheckTestCaseMixin,
|
||||
DatabaseConversionMixin, OpenFileCheckTestCaseMixin,
|
||||
RandomPrimaryKeyModelMonkeyPatchMixin, TempfileCheckTestCasekMixin,
|
||||
TestViewTestCaseMixin
|
||||
RandomPrimaryKeyModelMonkeyPatchMixin, SilenceLoggerTestCaseMixin,
|
||||
TempfileCheckTestCasekMixin, TestViewTestCaseMixin
|
||||
)
|
||||
|
||||
|
||||
class BaseTestCase(RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixin, ACLTestCaseMixin, OpenFileCheckTestCaseMixin, TempfileCheckTestCasekMixin, TestCase):
|
||||
class BaseTestCase(SilenceLoggerTestCaseMixin, RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixin, ACLTestCaseMixin, OpenFileCheckTestCaseMixin, TempfileCheckTestCasekMixin, TestCase):
|
||||
"""
|
||||
This is the most basic test case class any test in the project should use.
|
||||
"""
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import glob
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
|
||||
@@ -209,6 +210,23 @@ class RandomPrimaryKeyModelMonkeyPatchMixin(object):
|
||||
super(RandomPrimaryKeyModelMonkeyPatchMixin, self).tearDown()
|
||||
|
||||
|
||||
class SilenceLoggerTestCaseMixin(object):
|
||||
test_case_logger = None
|
||||
|
||||
def tearDown(self):
|
||||
if self.test_case_logger:
|
||||
self.test_case_logger.setLevel(level=self.test_case_logger_level)
|
||||
|
||||
super(SilenceLoggerTestCaseMixin, self).tearDown()
|
||||
|
||||
def _silence_logger(self, name):
|
||||
self.test_case_logger = logging.getLogger(name=name)
|
||||
self.test_case_logger_level = self.test_case_logger.level
|
||||
self.test_case_logger.setLevel(
|
||||
level=logging.CRITICAL
|
||||
)
|
||||
|
||||
|
||||
class TempfileCheckTestCasekMixin(object):
|
||||
# Ignore the jvmstat instrumentation and GitLab's CI .config files
|
||||
# Ignore LibreOffice fontconfig cache dir
|
||||
|
||||
@@ -112,6 +112,8 @@ class TransformationBaseTestCase(TestCase):
|
||||
|
||||
class TransformationTestCase(GenericDocumentTestCase):
|
||||
def test_crop_transformation_optional_arguments(self):
|
||||
self._silence_logger(name='mayan.apps.converter.managers')
|
||||
|
||||
document_page = self.document.pages.first()
|
||||
|
||||
Transformation.objects.add_for_model(
|
||||
@@ -122,6 +124,8 @@ class TransformationTestCase(GenericDocumentTestCase):
|
||||
self.assertTrue(document_page.generate_image().startswith('page'))
|
||||
|
||||
def test_crop_transformation_invalid_arguments(self):
|
||||
self._silence_logger(name='mayan.apps.converter.managers')
|
||||
|
||||
document_page = self.document.pages.first()
|
||||
|
||||
Transformation.objects.add_for_model(
|
||||
@@ -132,6 +136,8 @@ class TransformationTestCase(GenericDocumentTestCase):
|
||||
self.assertTrue(document_page.generate_image().startswith('page'))
|
||||
|
||||
def test_crop_transformation_non_valid_range_arguments(self):
|
||||
self._silence_logger(name='mayan.apps.converter.managers')
|
||||
|
||||
document_page = self.document.pages.first()
|
||||
|
||||
Transformation.objects.add_for_model(
|
||||
@@ -142,6 +148,8 @@ class TransformationTestCase(GenericDocumentTestCase):
|
||||
self.assertTrue(document_page.generate_image().startswith('page'))
|
||||
|
||||
def test_crop_transformation_overlapping_ranges_arguments(self):
|
||||
self._silence_logger(name='mayan.apps.converter.managers')
|
||||
|
||||
document_page = self.document.pages.first()
|
||||
|
||||
Transformation.objects.add_for_model(
|
||||
|
||||
Reference in New Issue
Block a user