Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import os
  2. import django
  3. from django.conf import settings, global_settings
  4. import oscar
  5. def configure():
  6. if not settings.configured:
  7. from oscar.defaults import OSCAR_SETTINGS
  8. # Helper function to extract absolute path
  9. location = lambda x: os.path.join(
  10. os.path.dirname(os.path.realpath(__file__)), x)
  11. test_settings = OSCAR_SETTINGS.copy()
  12. test_settings.update({
  13. 'DATABASES': {
  14. 'default': {
  15. 'ENGINE': 'django.db.backends.sqlite3',
  16. 'NAME': ':memory:',
  17. },
  18. },
  19. 'INSTALLED_APPS': [
  20. 'django.contrib.auth',
  21. 'django.contrib.admin',
  22. 'django.contrib.contenttypes',
  23. 'django.contrib.sessions',
  24. 'django.contrib.sites',
  25. 'django.contrib.flatpages',
  26. 'django.contrib.staticfiles',
  27. 'compressor',
  28. 'tests._site.model_tests_app', # contains models we need for testing
  29. 'tests._site.myauth',
  30. # Use a custom partner app to test overriding models. I can't
  31. # find a way of doing this on a per-test basis, so I'm using a
  32. # global change.
  33. ] + oscar.get_core_apps([
  34. 'tests._site.apps.partner',
  35. 'tests._site.apps.customer']),
  36. 'AUTH_USER_MODEL': 'myauth.User',
  37. 'TEMPLATE_CONTEXT_PROCESSORS': (
  38. "django.contrib.auth.context_processors.auth",
  39. "django.core.context_processors.request",
  40. "django.core.context_processors.debug",
  41. "django.core.context_processors.i18n",
  42. "django.core.context_processors.media",
  43. "django.core.context_processors.static",
  44. "django.contrib.messages.context_processors.messages",
  45. 'oscar.apps.search.context_processors.search_form',
  46. 'oscar.apps.customer.notifications.context_processors.notifications',
  47. 'oscar.apps.promotions.context_processors.promotions',
  48. 'oscar.apps.checkout.context_processors.checkout',
  49. 'oscar.core.context_processors.metadata',
  50. ),
  51. 'TEMPLATE_DIRS': (
  52. location('templates'),
  53. oscar.OSCAR_MAIN_TEMPLATE_DIR,
  54. ),
  55. 'TEMPLATE_LOADERS': (('django.template.loaders.cached.Loader',
  56. global_settings.TEMPLATE_LOADERS),),
  57. 'MIDDLEWARE_CLASSES': (
  58. 'django.middleware.common.CommonMiddleware',
  59. 'django.contrib.sessions.middleware.SessionMiddleware',
  60. 'django.middleware.csrf.CsrfViewMiddleware',
  61. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  62. 'django.contrib.messages.middleware.MessageMiddleware',
  63. 'oscar.apps.basket.middleware.BasketMiddleware',
  64. ),
  65. 'AUTHENTICATION_BACKENDS': (
  66. 'oscar.apps.customer.auth_backends.EmailBackend',
  67. 'django.contrib.auth.backends.ModelBackend',
  68. ),
  69. 'HAYSTACK_CONNECTIONS': {
  70. 'default': {
  71. 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  72. }
  73. },
  74. 'PASSWORD_HASHERS': ['django.contrib.auth.hashers.MD5PasswordHasher'],
  75. 'ROOT_URLCONF': 'tests._site.urls',
  76. 'LOGIN_REDIRECT_URL': '/accounts/',
  77. 'STATIC_URL': '/static/',
  78. 'COMPRESS_ENABLED': False,
  79. 'COMPRESS_ROOT': '', # needed to avoid issue #1214
  80. 'DEBUG': False,
  81. 'SITE_ID': 1,
  82. 'USE_TZ': 1,
  83. 'APPEND_SLASH': True,
  84. 'DDF_DEFAULT_DATA_FIXTURE': 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass',
  85. 'SESSION_SERIALIZER': 'django.contrib.sessions.serializers.JSONSerializer',
  86. # temporary workaround for issue in sorl-thumbnail in Python 3
  87. # https://github.com/mariocesar/sorl-thumbnail/pull/254
  88. 'THUMBNAIL_DEBUG': False,
  89. 'OSCAR_INITIAL_ORDER_STATUS': 'A',
  90. 'OSCAR_ORDER_STATUS_PIPELINE': {'A': ('B',), 'B': ()},
  91. 'OSCAR_INITIAL_LINE_STATUS': 'a',
  92. 'OSCAR_LINE_STATUS_PIPELINE': {'a': ('b', ), 'b': ()},
  93. # Setting this explicitly prevents Django 1.7+ from showing a
  94. # warning regarding a changed default test runner. The Oscar test
  95. # suite is run with nose anyway, so the value does not matter.
  96. 'TEST_RUNNER': 'foobar',
  97. })
  98. settings.configure(**test_settings)