test.py 3.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
"""
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
"""
from .common import *
import os
12 13
from path import path

14 15
# Nose Test Runner
INSTALLED_APPS += ('django_nose',)
16
NOSE_ARGS = ['--with-xunit']
17 18
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

19 20
TEST_ROOT = path('test_root')

21
# Makes the tests run much faster...
Calen Pennington committed
22
SOUTH_TESTS_MIGRATE = False   # To disable migrations and use syncdb instead
23

24
# Want static files in the same dir for running on jenkins.
25
STATIC_ROOT = TEST_ROOT / "staticfiles"
26

27
GITHUB_REPO_ROOT = TEST_ROOT / "data"
28 29
COMMON_TEST_DATA_ROOT = COMMON_ROOT / "test" / "data"

30 31 32
# Makes the tests run much faster...
SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead

33 34 35 36 37 38 39 40 41 42
# 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)
]
43

44 45 46 47 48 49 50 51 52
modulestore_options = {
    'default_class': 'xmodule.raw_module.RawDescriptor',
    'host': 'localhost',
    'db': 'test_xmodule',
    'collection': 'modulestore',
    'fs_root': GITHUB_REPO_ROOT,
    'render_template': 'mitxmako.shortcuts.render_to_string',
}

53
MODULESTORE = {
54 55
    'default': {
        'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
56 57 58 59 60
        'OPTIONS': modulestore_options
    },
    'direct': {
        'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
        'OPTIONS': modulestore_options
Chris Dodge committed
61 62 63 64
    },
    'draft': {
        'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore',
        'OPTIONS': modulestore_options
65
    }
66 67
}

68 69 70 71
CONTENTSTORE = {
    'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
    'OPTIONS': {
        'host': 'localhost',
Calen Pennington committed
72
        'db': 'xcontent',
73
    }
74 75 76 77 78
}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
79
        'NAME': ENV_ROOT / "db" / "cms.db",
80
    },
81 82
}

cahrens committed
83 84
LMS_BASE = "localhost:8000"

85
CACHES = {
Calen Pennington committed
86
    # This is the cache used for most things. Askbot will not work without a
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    # 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',
105 106 107 108 109 110 111
    },

    'mongo_metadata_inheritance': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': '/var/tmp/mongo_metadata_inheritance',
        'TIMEOUT': 300,
        'KEY_FUNCTION': 'util.memcache.safe_key',
112 113
    }
}
114 115 116 117 118 119

################### Make tests faster
#http://slacy.com/blog/2012/04/make-your-tests-faster-in-django-1-4/
PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
120
)
121

122 123
# dummy segment-io key
SEGMENT_IO_KEY = '***REMOVED***'