test_static_optimized.py 1.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
"""
Settings used when generating static assets for use in tests.

For example, Bok Choy uses two different settings files:
1. test_static_optimized is used when invoking collectstatic
2. bok_choy is used when running CMS and LMS

Note: it isn't possible to have a single settings file, because Django doesn't
support both generating static assets to a directory and also serving static
from the same directory.
"""

13 14
# Start with the common settings
from .common import *  # pylint: disable=wildcard-import, unused-wildcard-import
15
from openedx.core.lib.derived import derive_settings
16

17 18 19 20
# Use an in-memory database since this settings file is only used for updating assets
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
21
        'ATOMIC_REQUESTS': True,
22
    },
23

24
}
25 26 27 28 29 30 31 32

######################### PIPELINE ####################################

# Use RequireJS optimized storage
STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage'

# Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline
STATICFILES_FINDERS = [
33 34
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
35
    'openedx.core.lib.xblock_pipeline.finder.XBlockPipelineFinder',
36
]
37

38
# Redirect to the test_root folder within the repo
39
TEST_ROOT = REPO_ROOT / "test_root"
40 41
LOG_DIR = (TEST_ROOT / "log").abspath()

42 43
# Store the static files under test root so that they don't overwrite existing static assets
STATIC_ROOT = (TEST_ROOT / "staticfiles" / "cms").abspath()
44
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
45

46
# Disable uglify when tests are running (used by build.js).
47 48 49
# 1. Uglify is by far the slowest part of the build process
# 2. Having full source code makes debugging tests easier for developers
os.environ['REQUIRE_BUILD_PROFILE_OPTIMIZE'] = 'none'
50 51 52 53

########################## Derive Any Derived Settings  #######################

derive_settings(__name__)