Beispiel #1
0
 def pre_setup(cls):
     """
     Set the default values for fancypages and oscar from their respective
     settings dictionaries before setting up/overwriting them on the
     configurations class.
     """
     super(OscarFancypages, cls).pre_setup()
     from oscar.defaults import OSCAR_SETTINGS
     for key, value in OSCAR_SETTINGS.iteritems():
         if not hasattr(cls, key):
             setattr(cls, key, value)
Beispiel #2
0
    def pre_setup(cls):
        """
        Set the default values for fancypages and oscar from their respective
        settings dictionaries before setting up/overwriting them on the
        configurations class.
        """
        super(OscarFancypages, cls).pre_setup()
        from oscar.defaults import OSCAR_SETTINGS

        for key, value in OSCAR_SETTINGS.iteritems():
            if not hasattr(cls, key):
                setattr(cls, key, value)
Beispiel #3
0
def configure():
    if not settings.configured:
        from oscar.defaults import OSCAR_SETTINGS

        # Helper function to extract absolute path
        location = lambda x: os.path.join(
            os.path.dirname(os.path.realpath(__file__)), x)

        test_settings = OSCAR_SETTINGS.copy()
        test_settings.update({
            'DATABASES': {
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': ':memory:',
                },
            },
            'INSTALLED_APPS': [
                'django.contrib.auth',
                'django.contrib.admin',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'django.contrib.sites',
                'django.contrib.flatpages',
                'django.contrib.staticfiles',
                'compressor',
                'tests._site.model_tests_app',  # contains models we need for testing
                'tests._site.myauth',

                # Use a custom partner app to test overriding models.  I can't
                # find a way of doing this on a per-test basis, so I'm using a
                # global change.
            ] + oscar.get_core_apps([
                'tests._site.apps.partner',
                'tests._site.apps.customer']),
            'AUTH_USER_MODEL': 'myauth.User',
            '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",
                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.customer.notifications.context_processors.notifications',
                'oscar.apps.promotions.context_processors.promotions',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.core.context_processors.metadata',
            ),
            'TEMPLATE_DIRS': (
                location('templates'),
                oscar.OSCAR_MAIN_TEMPLATE_DIR,
            ),
            'TEMPLATE_LOADERS': (('django.template.loaders.cached.Loader',
                                     global_settings.TEMPLATE_LOADERS),),
            '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',
            ),
            'AUTHENTICATION_BACKENDS': (
                'oscar.apps.customer.auth_backends.EmailBackend',
                'django.contrib.auth.backends.ModelBackend',
            ),
            'HAYSTACK_CONNECTIONS': {
                'default': {
                    'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
                }
            },
            'PASSWORD_HASHERS': ['django.contrib.auth.hashers.MD5PasswordHasher'],
            'ROOT_URLCONF': 'tests._site.urls',
            'LOGIN_REDIRECT_URL': '/accounts/',
            'STATIC_URL': '/static/',
            'COMPRESS_ENABLED': False,
            'COMPRESS_ROOT': '',  # needed to avoid issue #1214
            'DEBUG': False,
            'SITE_ID': 1,
            'USE_TZ': 1,
            'APPEND_SLASH': True,
            'DDF_DEFAULT_DATA_FIXTURE': 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass',
            'SESSION_SERIALIZER': 'django.contrib.sessions.serializers.JSONSerializer',

            # temporary workaround for issue in sorl-thumbnail in Python 3
            # https://github.com/mariocesar/sorl-thumbnail/pull/254
            'THUMBNAIL_DEBUG': False,

            'OSCAR_INITIAL_ORDER_STATUS': 'A',
            'OSCAR_ORDER_STATUS_PIPELINE': {'A': ('B',), 'B': ()},
            'OSCAR_INITIAL_LINE_STATUS': 'a',
            'OSCAR_LINE_STATUS_PIPELINE': {'a': ('b', ), 'b': ()},

            # Setting this explicitly prevents Django 1.7+ from showing a
            # warning regarding a changed default test runner. The Oscar test
            # suite is run with nose anyway, so the value does not matter.
            'TEST_RUNNER': 'foobar',
        })

        settings.configure(**test_settings)
Beispiel #4
0
def configure():
    if not settings.configured:
        from oscar.defaults import OSCAR_SETTINGS

        # Helper function to extract absolute path
        location = lambda x: os.path.join(
            os.path.dirname(os.path.realpath(__file__)), x)

        test_settings = OSCAR_SETTINGS.copy()
        test_settings.update({
            'DATABASES': {
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': ':memory:',
                },
            },
            'INSTALLED_APPS': [
                'django.contrib.auth',
                'django.contrib.admin',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'django.contrib.sites',
                'django.contrib.flatpages',
                'django.contrib.staticfiles',
                'compressor',
                'tests._site.model_tests_app',  # contains models we need for testing
                'tests._site.myauth',

                # Use a custom partner app to test overriding models.  I can't
                # find a way of doing this on a per-test basis, so I'm using a
                # global change.
            ] + oscar.get_core_apps(
                ['tests._site.apps.partner', 'tests._site.apps.customer']),
            'AUTH_USER_MODEL':
            'myauth.User',
            '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",
                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.customer.notifications.context_processors.notifications',
                'oscar.apps.promotions.context_processors.promotions',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.core.context_processors.metadata',
            ),
            'TEMPLATE_DIRS': (
                location('templates'),
                oscar.OSCAR_MAIN_TEMPLATE_DIR,
            ),
            'TEMPLATE_LOADERS': (('django.template.loaders.cached.Loader', [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader'
            ]), ),
            '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',
            ),
            'AUTHENTICATION_BACKENDS': (
                'oscar.apps.customer.auth_backends.EmailBackend',
                'django.contrib.auth.backends.ModelBackend',
            ),
            'HAYSTACK_CONNECTIONS': {
                'default': {
                    'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
                }
            },
            'PASSWORD_HASHERS':
            ['django.contrib.auth.hashers.MD5PasswordHasher'],
            'ROOT_URLCONF':
            'tests._site.urls',
            'LOGIN_REDIRECT_URL':
            '/accounts/',
            'STATIC_URL':
            '/static/',
            'COMPRESS_ENABLED':
            False,
            'COMPRESS_ROOT':
            '',  # needed to avoid issue #1214
            'DEBUG':
            False,
            'SITE_ID':
            1,
            'USE_TZ':
            1,
            'APPEND_SLASH':
            True,
            'DDF_DEFAULT_DATA_FIXTURE':
            'tests.dynamic_fixtures.OscarDynamicDataFixtureClass',
            'SESSION_SERIALIZER':
            'django.contrib.sessions.serializers.JSONSerializer',

            # temporary workaround for issue in sorl-thumbnail in Python 3
            # https://github.com/mariocesar/sorl-thumbnail/pull/254
            'THUMBNAIL_DEBUG':
            False,
            'OSCAR_INITIAL_ORDER_STATUS':
            'A',
            'OSCAR_ORDER_STATUS_PIPELINE': {
                'A': ('B', ),
                'B': ()
            },
            'OSCAR_INITIAL_LINE_STATUS':
            'a',
            'OSCAR_LINE_STATUS_PIPELINE': {
                'a': ('b', ),
                'b': ()
            },

            # Setting this explicitly prevents Django 1.7+ from showing a
            # warning regarding a changed default test runner. The Oscar test
            # suite is run with nose, so it does not matter.
            'SILENCED_SYSTEM_CHECKS': ['1_6.W001'],
        })

        settings.configure(**test_settings)
def pytest_configure():
    location = lambda x: os.path.join(
        os.path.dirname(os.path.realpath(__file__)), x)

    test_settings = OSCAR_SETTINGS.copy()
    test_settings.update(dict(
        DATABASES={
            'default': {
                'ENGINE': 'django.contrib.gis.db.backends.postgis',
                'NAME': 'oscar_stores',
                'HOST': '127.0.0.1',
            }
        },
        SITE_ID=1,
        MEDIA_ROOT=location('public/media'),
        MEDIA_URL='/media/',
        STATIC_URL='/static/',
        STATICFILES_DIRS=(location('static/'),),
        STATIC_ROOT=location('public'),
        STATICFILES_FINDERS=(
            'django.contrib.staticfiles.finders.FileSystemFinder',
            'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        ),
        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=(
            location('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.admin',
            'django.contrib.gis',
            'django.contrib.flatpages',
            'compressor',
            'widget_tweaks',
        ] + get_core_apps() + [
            'stores',
        ],
        AUTHENTICATION_BACKENDS=(
            'oscar.apps.customer.auth_backends.Emailbackend',
            'django.contrib.auth.backends.ModelBackend',
        ),
        LOGIN_REDIRECT_URL='/accounts/',
        APPEND_SLASH=True,
        HAYSTACK_CONNECTIONS={
            'default': {
                'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
            },
        },
        GEOIP_PATH='sandbox/geoip',
        COMPRESS_ENABLED=False,
        TEST_RUNNER='django.test.runner.DiscoverRunner',
    ))
    settings.configure(**test_settings)
def pytest_configure():
    location = lambda x: os.path.join(
        os.path.dirname(os.path.realpath(__file__)), x)

    test_settings = OSCAR_SETTINGS.copy()
    test_settings.update(
        dict(
            DATABASES={
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.postgis',
                    'NAME': 'oscar_stores',
                }
            },
            SITE_ID=1,
            MEDIA_ROOT=location('public/media'),
            MEDIA_URL='/media/',
            STATIC_URL='/static/',
            STATICFILES_DIRS=(location('static/'), ),
            STATIC_ROOT=location('public'),
            STATICFILES_FINDERS=(
                'django.contrib.staticfiles.finders.FileSystemFinder',
                'django.contrib.staticfiles.finders.AppDirectoriesFinder',
            ),
            TEMPLATES=[{
                'BACKEND':
                'django.template.backends.django.DjangoTemplates',
                'DIRS': [
                    location('templates'),
                    OSCAR_MAIN_TEMPLATE_DIR,
                ],
                'OPTIONS': {
                    'loaders': [
                        'django.template.loaders.filesystem.Loader',
                        'django.template.loaders.app_directories.Loader',
                    ],
                    'context_processors': [
                        'django.contrib.auth.context_processors.auth',
                        'django.template.context_processors.request',
                        'django.template.context_processors.debug',
                        'django.template.context_processors.i18n',
                        'django.template.context_processors.media',
                        'django.template.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=(
                location('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.admin',
                'django.contrib.gis',
                'django.contrib.flatpages',
                'widget_tweaks',
            ] + get_core_apps() + [
                'stores',
            ],
            AUTHENTICATION_BACKENDS=(
                'oscar.apps.customer.auth_backends.EmailBackend',
                'django.contrib.auth.backends.ModelBackend',
            ),
            LOGIN_REDIRECT_URL='/accounts/',
            APPEND_SLASH=True,
            HAYSTACK_CONNECTIONS={
                'default': {
                    'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
                },
            },
            GEOIP_PATH='sandbox/geoip',
            COMPRESS_ENABLED=False,
            TEST_RUNNER='django.test.runner.DiscoverRunner',
        ))

    settings.configure(**test_settings)