diff --git a/mayan/apps/checkouts/tests/test_models.py b/mayan/apps/checkouts/tests/test_models.py index bbf6659778..083cd78a50 100644 --- a/mayan/apps/checkouts/tests/test_models.py +++ b/mayan/apps/checkouts/tests/test_models.py @@ -104,14 +104,14 @@ class DocumentCheckoutTestCase(BaseTestCase): self.document.check_in() def test_auto_checkin(self): - expiration_datetime = now() + datetime.timedelta(seconds=1) + expiration_datetime = now() + datetime.timedelta(seconds=.1) DocumentCheckout.objects.checkout_document( document=self.document, expiration_datetime=expiration_datetime, user=self.admin_user, block_new_version=True ) - time.sleep(2) + time.sleep(.11) DocumentCheckout.objects.check_in_expired_check_outs() diff --git a/mayan/apps/document_signatures/tests/test_models.py b/mayan/apps/document_signatures/tests/test_models.py index a0da6be8cf..a17607a786 100644 --- a/mayan/apps/document_signatures/tests/test_models.py +++ b/mayan/apps/document_signatures/tests/test_models.py @@ -240,7 +240,7 @@ class DocumentSignaturesTestCase(BaseTestCase): # Artifical delay since MySQL doesn't store microsecond data in # timestamps. Version timestamp is used to determine which version # is the latest. - time.sleep(2) + time.sleep(1) self.assertEqual(EmbeddedSignature.objects.count(), 1) @@ -264,8 +264,8 @@ class EmbeddedSignaturesTestCase(BaseTestCase): super(EmbeddedSignaturesTestCase, self).tearDown() def test_unsigned_document_version_method(self): - TEST_UNSIGNED_DOCUMENT_COUNT = 3 - TEST_SIGNED_DOCUMENT_COUNT = 3 + TEST_UNSIGNED_DOCUMENT_COUNT = 2 + TEST_SIGNED_DOCUMENT_COUNT = 2 for count in range(TEST_UNSIGNED_DOCUMENT_COUNT): with open(TEST_DOCUMENT_PATH) as file_object: @@ -292,7 +292,7 @@ class EmbeddedSignaturesTestCase(BaseTestCase): DocumentVersion._post_save_hooks = {} - TEST_UNSIGNED_DOCUMENT_COUNT = 4 + TEST_UNSIGNED_DOCUMENT_COUNT = 2 TEST_SIGNED_DOCUMENT_COUNT = 2 for count in range(TEST_UNSIGNED_DOCUMENT_COUNT): diff --git a/mayan/apps/documents/tests/test_models.py b/mayan/apps/documents/tests/test_models.py index 25786aa361..59816015c3 100644 --- a/mayan/apps/documents/tests/test_models.py +++ b/mayan/apps/documents/tests/test_models.py @@ -102,7 +102,7 @@ class DocumentTestCase(BaseTestCase): # Needed by MySQL as milliseconds value is not store in timestamp # field - time.sleep(2) + time.sleep(1.01) self.assertEqual(Document.objects.count(), 1) self.assertEqual(DeletedDocument.objects.count(), 0) @@ -130,9 +130,9 @@ class DocumentTestCase(BaseTestCase): self.assertEqual(Document.objects.count(), 0) self.assertEqual(DeletedDocument.objects.count(), 1) - # Needed by MySQL as milliseconds value is not store in timestamp + # Needed by MySQL as milliseconds value is not stored in timestamp # field - time.sleep(2) + time.sleep(1.01) DocumentType.objects.check_delete_periods() @@ -235,7 +235,7 @@ class DocumentVersionTestCase(GenericDocumentTestCase): # Needed by MySQL as milliseconds value is not store in timestamp # field - time.sleep(2) + time.sleep(1.01) with open(TEST_DOCUMENT_PATH) as file_object: self.document.new_version( diff --git a/mayan/settings/testing/base.py b/mayan/settings/testing/base.py index 617da6cd62..4f5ad241ee 100644 --- a/mayan/settings/testing/base.py +++ b/mayan/settings/testing/base.py @@ -10,15 +10,43 @@ INSTALLED_APPS = [ COMMON_PRODUCTION_ERROR_LOG_PATH = '/tmp/mayan-errors.log' -TEMPLATES[0]['OPTIONS']['loaders'] = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - # Remove whitenoise from middlewares. Causes out of memory errors during test # suit MIDDLEWARE_CLASSES = [ cls for cls in MIDDLEWARE_CLASSES if cls != 'whitenoise.middleware.WhiteNoiseMiddleware' ] +# User a simpler password hasher +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.MD5PasswordHasher', +) + STATICFILES_STORAGE = None + +# Cache templates in memory +TEMPLATES[0]['OPTIONS']['loaders'] = ( + ( + 'django.template.loaders.cached.Loader', ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ) + ), +) + +CELERY_ALWAYS_EAGER = True +CELERY_EAGER_PROPAGATES_EXCEPTIONS = True +BROKER_BACKEND = 'memory' + +# Remove middlewares not used for tests +MIDDLEWARE_CLASSES = [ + cls for cls in MIDDLEWARE_CLASSES if cls not in [ + 'common.middleware.error_logging.ErrorLoggingMiddleware', + 'django.middleware.security.SecurityMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'common.middleware.timezone.TimezoneMiddleware', + 'common.middleware.ajax_redirect.AjaxRedirect', + ] +]