diff --git a/mayan/apps/common/tests/base.py b/mayan/apps/common/tests/base.py index c3c06672c5..28edf1b4a5 100644 --- a/mayan/apps/common/tests/base.py +++ b/mayan/apps/common/tests/base.py @@ -14,7 +14,7 @@ from .mixins import ( ) -class BaseTestCase(RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixin, ACLTestCaseMixin, ContentTypeCheckMixin, OpenFileCheckTestCaseMixin, TempfileCheckTestCaseMixin, TestCase): +class BaseTestCase(RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixin, ACLTestCaseMixin, OpenFileCheckTestCaseMixin, TempfileCheckTestCaseMixin, TestCase): """ This is the most basic test case class any test in the project should use. """ @@ -26,7 +26,7 @@ class BaseTestCase(RandomPrimaryKeyModelMonkeyPatchMixin, DatabaseConversionMixi Permission.invalidate_cache() -class GenericViewTestCase(ClientMethodsTestCaseMixin, TestViewTestCaseMixin, BaseTestCase): +class GenericViewTestCase(ClientMethodsTestCaseMixin, ContentTypeCheckMixin, TestViewTestCaseMixin, BaseTestCase): """ A generic view test case built on top of the base test case providing a single, user customizable view to test object resolution and shorthand diff --git a/mayan/apps/common/tests/mixins.py b/mayan/apps/common/tests/mixins.py index 9898d38d63..a729e7d280 100644 --- a/mayan/apps/common/tests/mixins.py +++ b/mayan/apps/common/tests/mixins.py @@ -90,13 +90,14 @@ class ContentTypeCheckMixin(object): def request(self, *args, **kwargs): response = super(CustomClient, self).request(*args, **kwargs) - content_type = response._headers['content-type'][1] - test_instance.assertEqual( - content_type, test_instance.expected_content_type, - msg='Unexpected response content type: {}, expected: {}.'.format( - content_type, test_instance.expected_content_type + content_type = response._headers.get('content-type', [None, ''])[1] + if test_instance.expected_content_type: + test_instance.assertEqual( + content_type, test_instance.expected_content_type, + msg='Unexpected response content type: {}, expected: {}.'.format( + content_type, test_instance.expected_content_type + ) ) - ) return response