acceptance.py 3.25 KB
Newer Older
1
"""
Calen Pennington committed
2
This config file extends the test environment configuration
3 4
so that we can run the lettuce acceptance tests.
"""
5 6 7 8 9

# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614

10
from .test import *
11
from lms.envs.sauce import *
12 13 14 15 16

# You need to start the server in debug mode,
# otherwise the browser will not render the pages correctly
DEBUG = True

17 18 19
# Disable warnings for acceptance tests, to make the logs readable
import logging
logging.disable(logging.ERROR)
20
import os
21
from random import choice, randint
22 23 24 25


def seed():
    return os.getppid()
26

27
DOC_STORE_CONFIG = {
28
    'host': 'localhost',
29
    'db': 'acceptance_xmodule',
30
    'collection': 'acceptance_modulestore_%s' % seed(),
31 32
}

33
MODULESTORE_OPTIONS = dict({
34
    'default_class': 'xmodule.raw_module.RawDescriptor',
35
    'fs_root': TEST_ROOT / "data",
36
    'render_template': 'mitxmako.shortcuts.render_to_string',
37
}, **DOC_STORE_CONFIG)
38 39 40

MODULESTORE = {
    'default': {
41
        'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore',
42 43 44 45 46 47 48
        'OPTIONS': MODULESTORE_OPTIONS
    },
    'direct': {
        'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
        'OPTIONS': MODULESTORE_OPTIONS
    },
    'draft': {
49
        'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore',
50 51 52
        'OPTIONS': MODULESTORE_OPTIONS
    }
}
53 54 55

CONTENTSTORE = {
    'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
56
    'OPTIONS': {
57
        'host': 'localhost',
58
        'db': 'acceptance_xcontent_%s' % seed(),
59 60 61 62 63 64 65 66 67
    },
    # allow for additional options that can be keyed on a name, e.g. 'trashcan'
    'ADDITIONAL_OPTIONS': {
        'trashcan': {
            'bucket': 'trash_fs'
        }
    }
}

Calen Pennington committed
68
# Set this up so that rake lms[acceptance] and running the
69 70 71 72 73
# harvest command both use the same (test) database
# which they can flush without messing up your dev db
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
74 75
        'NAME': TEST_ROOT / "db" / "test_edx.db",
        'TEST_NAME': TEST_ROOT / "db" / "test_edx.db"
76 77 78
    }
}

79 80 81
# Use the auto_auth workflow for creating users and logging them in
MITX_FEATURES['AUTOMATIC_AUTH_FOR_TESTING'] = True

82 83 84 85 86
# HACK
# Setting this flag to false causes imports to not load correctly in the lettuce python files
# We do not yet understand why this occurs. Setting this to true is a stopgap measure
USE_I18N = True

87 88 89
# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command
INSTALLED_APPS += ('lettuce.django',)
LETTUCE_APPS = ('contentstore',)
90
LETTUCE_BROWSER = os.environ.get('LETTUCE_BROWSER', 'chrome')
91

92 93 94 95 96 97 98 99
# Where to run: local, saucelabs, or grid
LETTUCE_SELENIUM_CLIENT = os.environ.get('LETTUCE_SELENIUM_CLIENT', 'local')

SELENIUM_GRID = {
    'URL': 'http://127.0.0.1:4444/wd/hub',
    'BROWSER': LETTUCE_BROWSER,
}

100 101 102
#####################################################################
# Lastly, see if the developer has any local overrides.
try:
103
    from .private import *  # pylint: disable=F0401
104 105
except ImportError:
    pass
106 107 108 109 110 111 112

# Because an override for where to run will affect which ports to use,
# set this up after the local overrides.
if LETTUCE_SELENIUM_CLIENT == 'saucelabs':
    LETTUCE_SERVER_PORT = choice(PORTS)
else:
    LETTUCE_SERVER_PORT = randint(1024, 65535)