test.py 5.12 KB
Newer Older
1 2 3 4 5 6 7 8 9
"""
This config file runs the simplest dev environment using sqlite, and db-based
sessions. Assumes structure:

/envroot/
        /db   # This is where it'll write the database file
        /mitx # The location of this repo
        /log  # Where we're going to write log files
"""
10 11 12 13 14

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

15 16
from .common import *
import os
17
from path import path
Diana Huang committed
18
from warnings import filterwarnings
19

20 21 22
# Nose Test Runner
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

23 24 25 26 27 28 29 30 31
_system = 'cms'
_report_dir = REPO_ROOT / 'reports' / _system
_report_dir.makedirs_p()

NOSE_ARGS = [
    '--id-file', REPO_ROOT / '.testids' / _system / 'noseids',
    '--xunit-file', _report_dir / 'nosetests.xml',
]

32 33 34
TEST_ROOT = path('test_root')

# Want static files in the same dir for running on jenkins.
35
STATIC_ROOT = TEST_ROOT / "staticfiles"
36

37
GITHUB_REPO_ROOT = TEST_ROOT / "data"
38 39
COMMON_TEST_DATA_ROOT = COMMON_ROOT / "test" / "data"

40
# Makes the tests run much faster...
41
SOUTH_TESTS_MIGRATE = False  # To disable migrations and use syncdb instead
42

43 44 45 46 47 48 49 50 51 52
# TODO (cpennington): We need to figure out how envs/test.py can inject things into common.py so that we don't have to repeat this sort of thing
STATICFILES_DIRS = [
    COMMON_ROOT / "static",
    PROJECT_ROOT / "static",
]
STATICFILES_DIRS += [
    (course_dir, COMMON_TEST_DATA_ROOT / course_dir)
    for course_dir in os.listdir(COMMON_TEST_DATA_ROOT)
    if os.path.isdir(COMMON_TEST_DATA_ROOT / course_dir)
]
53

54
DOC_STORE_CONFIG = {
55 56
    'host': 'localhost',
    'db': 'test_xmodule',
57
    'collection': 'test_modulestore',
58 59
}

60
MODULESTORE_OPTIONS = {
61
    'default_class': 'xmodule.raw_module.RawDescriptor',
62
    'fs_root': TEST_ROOT / "data",
63
    'render_template': 'mitxmako.shortcuts.render_to_string',
64
}
65

66
MODULESTORE = {
67
    'default': {
68
        'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore',
69
        'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
70
        'OPTIONS': MODULESTORE_OPTIONS
71 72 73
    },
    'direct': {
        'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
74
        'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
75
        'OPTIONS': MODULESTORE_OPTIONS
Chris Dodge committed
76 77
    },
    'draft': {
78
        'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore',
79
        'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
80
        'OPTIONS': MODULESTORE_OPTIONS
81 82 83
    },
    'split': {
        'ENGINE': 'xmodule.modulestore.split_mongo.SplitMongoModuleStore',
84
        'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
85
        'OPTIONS': MODULESTORE_OPTIONS
86
    }
87 88
}

89 90
CONTENTSTORE = {
    'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
91
    'DOC_STORE_CONFIG': {
92
        'host': 'localhost',
93
        'db': 'test_xcontent',
94
        'collection': 'dont_trip',
95 96 97 98 99 100
    },
    # allow for additional options that can be keyed on a name, e.g. 'trashcan'
    'ADDITIONAL_OPTIONS': {
        'trashcan': {
            'bucket': 'trash_fs'
        }
101
    }
102 103 104 105 106
}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
107
        'NAME': TEST_ROOT / "db" / "cms.db",
108
    },
109 110
}

cahrens committed
111
LMS_BASE = "localhost:8000"
112
MITX_FEATURES['PREVIEW_LMS_BASE'] = "preview"
cahrens committed
113

114
CACHES = {
Calen Pennington committed
115
    # This is the cache used for most things. Askbot will not work without a
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    # functioning cache -- it relies on caching to load its settings in places.
    # In staging/prod envs, the sessions also live here.
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'mitx_loc_mem_cache',
        'KEY_FUNCTION': 'util.memcache.safe_key',
    },

    # The general cache is what you get if you use our util.cache. It's used for
    # things like caching the course.xml file for different A/B test groups.
    # We set it to be a DummyCache to force reloading of course.xml in dev.
    # In staging environments, we would grab VERSION from data uploaded by the
    # push process.
    'general': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
        'KEY_PREFIX': 'general',
        'VERSION': 4,
        'KEY_FUNCTION': 'util.memcache.safe_key',
134 135 136 137 138 139 140
    },

    'mongo_metadata_inheritance': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': '/var/tmp/mongo_metadata_inheritance',
        'TIMEOUT': 300,
        'KEY_FUNCTION': 'util.memcache.safe_key',
141 142
    }
}
143

Diana Huang committed
144 145 146
# hide ratelimit warnings while running tests
filterwarnings('ignore', message='No request passed to the backend, unable to rate-limit')

147 148 149 150 151 152
################################# CELERY ######################################

CELERY_ALWAYS_EAGER = True
CELERY_RESULT_BACKEND = 'cache'
BROKER_TRANSPORT = 'memory'

153
################### Make tests faster
Don Mitchell committed
154
# http://slacy.com/blog/2012/04/make-your-tests-faster-in-django-1-4/
155 156 157
PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
158
)
159

160 161
# dummy segment-io key
SEGMENT_IO_KEY = '***REMOVED***'
162 163 164 165

# disable NPS survey in test mode
MITX_FEATURES['STUDIO_NPS_SURVEY'] = False

166
MITX_FEATURES['ENABLE_SERVICE_STATUS'] = True
Adam Palay committed
167

168 169
# This is to disable a test under the common directory that will not pass when run under CMS
MITX_FEATURES['DISABLE_PASSWORD_RESET_EMAIL_TEST'] = True