選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

config.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = {
  12. 'DATABASES': {
  13. 'default': {
  14. 'ENGINE': 'django.db.backends.sqlite3',
  15. 'NAME': ':memory:',
  16. },
  17. },
  18. 'INSTALLED_APPS': [
  19. 'django.contrib.auth',
  20. 'django.contrib.admin',
  21. 'django.contrib.contenttypes',
  22. 'django.contrib.sessions',
  23. 'django.contrib.sites',
  24. 'django.contrib.flatpages',
  25. 'django.contrib.staticfiles',
  26. 'sorl.thumbnail',
  27. 'compressor',
  28. 'tests._site.model_tests_app', # contains models we need for testing
  29. # Use a custom partner app to test overriding models. I can't
  30. # find a way of doing this on a per-test basis, so I'm using a
  31. # global change.
  32. ] + oscar.get_core_apps(['tests._site.apps.partner']),
  33. 'TEMPLATE_CONTEXT_PROCESSORS': (
  34. "django.contrib.auth.context_processors.auth",
  35. "django.core.context_processors.request",
  36. "django.core.context_processors.debug",
  37. "django.core.context_processors.i18n",
  38. "django.core.context_processors.media",
  39. "django.core.context_processors.static",
  40. "django.contrib.messages.context_processors.messages",
  41. 'oscar.apps.search.context_processors.search_form',
  42. 'oscar.apps.customer.notifications.context_processors.notifications',
  43. 'oscar.apps.promotions.context_processors.promotions',
  44. 'oscar.apps.checkout.context_processors.checkout',
  45. 'oscar.core.context_processors.metadata',
  46. ),
  47. 'TEMPLATE_DIRS': (
  48. location('templates'),
  49. oscar.OSCAR_MAIN_TEMPLATE_DIR,
  50. ),
  51. 'TEMPLATE_LOADERS': (('django.template.loaders.cached.Loader',
  52. global_settings.TEMPLATE_LOADERS),),
  53. 'MIDDLEWARE_CLASSES': global_settings.MIDDLEWARE_CLASSES + (
  54. 'oscar.apps.basket.middleware.BasketMiddleware',
  55. ),
  56. 'AUTHENTICATION_BACKENDS': (
  57. 'oscar.apps.customer.auth_backends.Emailbackend',
  58. 'django.contrib.auth.backends.ModelBackend',
  59. ),
  60. 'HAYSTACK_CONNECTIONS': {
  61. 'default': {
  62. 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  63. }
  64. },
  65. 'PASSWORD_HASHERS': ['django.contrib.auth.hashers.MD5PasswordHasher'],
  66. 'ROOT_URLCONF': 'tests._site.urls',
  67. 'LOGIN_REDIRECT_URL': '/accounts/',
  68. 'STATIC_URL': '/static/',
  69. 'COMPRESS_ENABLED': False,
  70. 'COMPRESS_ROOT': '', # needed to avoid issue #1214
  71. 'ADMINS': ('admin@example.com',),
  72. 'DEBUG': False,
  73. 'SITE_ID': 1,
  74. 'USE_TZ': 1,
  75. 'APPEND_SLASH': True,
  76. 'DDF_DEFAULT_DATA_FIXTURE': 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass',
  77. 'SESSION_SERIALIZER': 'django.contrib.sessions.serializers.JSONSerializer',
  78. }
  79. if django.VERSION >= (1, 5):
  80. test_settings['INSTALLED_APPS'] += ['tests._site.myauth', ]
  81. test_settings['AUTH_USER_MODEL'] = 'myauth.User'
  82. test_settings.update(OSCAR_SETTINGS)
  83. settings.configure(**test_settings)