This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
conftest.py
150 lines (139 loc) · 4.9 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import os
import logging
from django.conf import settings
from oscar import OSCAR_MAIN_TEMPLATE_DIR, get_core_apps
location = lambda x: os.path.join(
os.path.dirname(os.path.realpath(__file__)), x
)
sandbox = lambda x: location("sandbox/%s" % x)
logging.basicConfig(level=logging.INFO)
def pytest_configure():
from oscar.defaults import OSCAR_SETTINGS
from oscar_mws.defaults import OSCAR_MWS_SETTINGS
DEFAULT_SETTINGS = OSCAR_SETTINGS
DEFAULT_SETTINGS.update(OSCAR_MWS_SETTINGS)
DEFAULT_SETTINGS['OSCAR_DEFAULT_CURRENCY'] = 'USD'
# We use this to avoid throttling by MWS when checking the API.
# In the worst cases, the recovery rate is on request per minute which
# means setting it to a minute is playing it save.
INTEGRATION_WAIT_TIME = 60
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
},
USE_TZ=True,
MEDIA_ROOT=sandbox('public/media'),
MEDIA_URL='/media/',
STATIC_URL='/static/',
STATICFILES_DIRS=[
sandbox('static/')
],
STATIC_ROOT=sandbox('public'),
STATICFILES_FINDERS=(
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
),
TEMPLATE_LOADERS=(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.contrib.messages.context_processors.messages",
),
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'oscar.apps.basket.middleware.BasketMiddleware',
),
ROOT_URLCONF='sandbox.sandbox.urls',
TEMPLATE_DIRS=[
sandbox('templates'),
OSCAR_MAIN_TEMPLATE_DIR,
],
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'django.contrib.admin',
'compressor',
'south',
'oscar_mws',
] + get_core_apps(),
AUTHENTICATION_BACKENDS=(
'django.contrib.auth.backends.ModelBackend',
),
COMPRESS_ENABLED=True,
COMPRESS_OFFLINE=False,
COMPRESS_PRECOMPILERS=(
('text/less', 'lessc {infile} {outfile}'),
),
LOGIN_REDIRECT_URL='/accounts/',
APPEND_SLASH=True,
SITE_ID=1,
HAYSTACK_CONNECTIONS={
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
},
LOGGING={
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' # noqa
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
}
},
'loggers': {
'oscar_mws': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'oscar_mws.api': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'django.request': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
}
},
DEBUG=True,
INTEGRATION_WAIT_TIME=INTEGRATION_WAIT_TIME,
**DEFAULT_SETTINGS
)