acceptance.py 4.68 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

# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
8
# pylint: disable=wildcard-import, unused-wildcard-import
9

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
# Output Django logs to a file
18
import logging
19 20
logging.basicConfig(filename=TEST_ROOT / "log" / "cms_acceptance.log", level=logging.ERROR)

21 22 23
# set root logger level
logging.getLogger().setLevel(logging.ERROR)

24 25 26 27 28
import os


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

30 31 32 33 34 35 36 37 38 39
# Silence noisy logs
LOG_OVERRIDES = [
    ('track.middleware', logging.CRITICAL),
    ('codejail.safe_exec', logging.ERROR),
    ('edx.courseware', logging.ERROR),
    ('edxmako.shortcuts', logging.ERROR),
    ('audit', logging.ERROR),
    ('contentstore.views.import_export', logging.CRITICAL),
    ('xmodule.x_module', logging.CRITICAL),
]
40

41 42
for log_name, log_level in LOG_OVERRIDES:
    logging.getLogger(log_name).setLevel(log_level)
43

44 45 46 47 48
update_module_store_settings(
    MODULESTORE,
    doc_store_settings={
        'db': 'acceptance_xmodule',
        'collection': 'acceptance_modulestore_%s' % seed(),
49
    },
50 51 52
    module_store_options={
        'default_class': 'xmodule.raw_module.RawDescriptor',
        'fs_root': TEST_ROOT / "data",
53 54
    },
    default_store=os.environ.get('DEFAULT_STORE', 'draft'),
55
)
56 57 58

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

71
# Set this up so that 'paver cms --settings=acceptance' and running the
72 73 74 75 76
# 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',
77
        'NAME': TEST_ROOT / "db" / "test_edx.db",
78 79 80 81
        'TEST_NAME': TEST_ROOT / "db" / "test_edx.db",
        'OPTIONS': {
            'timeout': 30,
        },
82
        'ATOMIC_REQUESTS': True,
83 84 85 86 87 88 89 90
    },
    'student_module_history': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': TEST_ROOT / "db" / "test_student_module_history.db",
        'TEST_NAME': TEST_ROOT / "db" / "test_student_module_history.db",
        'OPTIONS': {
            'timeout': 30,
        },
91 92 93
    }
}

94
# Use the auto_auth workflow for creating users and logging them in
95
FEATURES['AUTOMATIC_AUTH_FOR_TESTING'] = True
96

97 98 99 100 101 102
# Forums are disabled in test.py to speed up unit tests, but we do not have
# per-test control for lettuce acceptance tests.
# If you are writing an acceptance test that needs the discussion service enabled,
# do not write it in lettuce, but instead write it using bok-choy.
# DO NOT CHANGE THIS SETTING HERE.
FEATURES['ENABLE_DISCUSSION_SERVICE'] = False
103

104 105 106 107 108
# 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

109
# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command
110 111
# django.contrib.staticfiles used to be loaded by lettuce, now we must add it ourselves
# django.contrib.staticfiles is not added to lms as there is a ^/static$ route built in to the app
112
INSTALLED_APPS += ('lettuce.django',)
113
LETTUCE_APPS = ('contentstore',)
114
LETTUCE_BROWSER = os.environ.get('LETTUCE_BROWSER', 'chrome')
115

116 117 118 119 120 121 122 123
# 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,
}

124 125 126
#####################################################################
# Lastly, see if the developer has any local overrides.
try:
127
    from .private import *  # pylint: disable=import-error
128 129
except ImportError:
    pass
130

131
# Point the URL used to test YouTube availability to our stub YouTube server
132 133
YOUTUBE['API'] = "http://127.0.0.1:{0}/get_youtube_api/".format(YOUTUBE_PORT)
YOUTUBE['METADATA_URL'] = "http://127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
134
YOUTUBE['TEXT_API']['url'] = "127.0.0.1:{0}/test_transcripts_youtube/".format(YOUTUBE_PORT)
135
YOUTUBE['TEST_TIMEOUT'] = 1500
136 137 138 139

# Generate a random UUID so that different runs of acceptance tests don't break each other
import uuid
SECRET_KEY = uuid.uuid4().hex
140 141 142 143

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

PIPELINE_ENABLED = False