PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/cms/envs/acceptance.py

https://gitlab.com/unofficial-mirrors/edx-platform
Python | 151 lines | 91 code | 25 blank | 35 comment | 5 complexity | 2f630f5fd8ded2d5d9fb7a8b24d5c2e0 MD5 | raw file
  1. """
  2. This config file extends the test environment configuration
  3. so that we can run the lettuce acceptance tests.
  4. """
  5. # We intentionally define lots of variables that aren't used, and
  6. # want to import all variables from base settings files
  7. # pylint: disable=wildcard-import, unused-wildcard-import
  8. from .test import *
  9. from lms.envs.sauce import *
  10. # You need to start the server in debug mode,
  11. # otherwise the browser will not render the pages correctly
  12. DEBUG = True
  13. # Output Django logs to a file
  14. import logging
  15. logging.basicConfig(filename=TEST_ROOT / "log" / "cms_acceptance.log", level=logging.ERROR)
  16. # set root logger level
  17. logging.getLogger().setLevel(logging.ERROR)
  18. import os
  19. def seed():
  20. return os.getppid()
  21. # Silence noisy logs
  22. LOG_OVERRIDES = [
  23. ('track.middleware', logging.CRITICAL),
  24. ('codejail.safe_exec', logging.ERROR),
  25. ('edx.courseware', logging.ERROR),
  26. ('edxmako.shortcuts', logging.ERROR),
  27. ('audit', logging.ERROR),
  28. ('contentstore.views.import_export', logging.CRITICAL),
  29. ('xmodule.x_module', logging.CRITICAL),
  30. ]
  31. for log_name, log_level in LOG_OVERRIDES:
  32. logging.getLogger(log_name).setLevel(log_level)
  33. update_module_store_settings(
  34. MODULESTORE,
  35. doc_store_settings={
  36. 'db': 'acceptance_xmodule',
  37. 'collection': 'acceptance_modulestore_%s' % seed(),
  38. },
  39. module_store_options={
  40. 'default_class': 'xmodule.raw_module.RawDescriptor',
  41. 'fs_root': TEST_ROOT / "data",
  42. },
  43. default_store=os.environ.get('DEFAULT_STORE', 'draft'),
  44. )
  45. CONTENTSTORE = {
  46. 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
  47. 'DOC_STORE_CONFIG': {
  48. 'host': 'localhost',
  49. 'db': 'acceptance_xcontent_%s' % seed(),
  50. },
  51. # allow for additional options that can be keyed on a name, e.g. 'trashcan'
  52. 'ADDITIONAL_OPTIONS': {
  53. 'trashcan': {
  54. 'bucket': 'trash_fs'
  55. }
  56. }
  57. }
  58. # Set this up so that 'paver cms --settings=acceptance' and running the
  59. # harvest command both use the same (test) database
  60. # which they can flush without messing up your dev db
  61. DATABASES = {
  62. 'default': {
  63. 'ENGINE': 'django.db.backends.sqlite3',
  64. 'NAME': TEST_ROOT / "db" / "test_edx.db",
  65. 'OPTIONS': {
  66. 'timeout': 30,
  67. },
  68. 'ATOMIC_REQUESTS': True,
  69. 'TEST': {
  70. 'NAME': TEST_ROOT / "db" / "test_edx.db",
  71. },
  72. },
  73. 'student_module_history': {
  74. 'ENGINE': 'django.db.backends.sqlite3',
  75. 'NAME': TEST_ROOT / "db" / "test_student_module_history.db",
  76. 'OPTIONS': {
  77. 'timeout': 30,
  78. },
  79. 'TEST': {
  80. 'NAME': TEST_ROOT / "db" / "test_student_module_history.db",
  81. },
  82. }
  83. }
  84. # Use the auto_auth workflow for creating users and logging them in
  85. FEATURES['AUTOMATIC_AUTH_FOR_TESTING'] = True
  86. # Forums are disabled in test.py to speed up unit tests, but we do not have
  87. # per-test control for lettuce acceptance tests.
  88. # If you are writing an acceptance test that needs the discussion service enabled,
  89. # do not write it in lettuce, but instead write it using bok-choy.
  90. # DO NOT CHANGE THIS SETTING HERE.
  91. FEATURES['ENABLE_DISCUSSION_SERVICE'] = False
  92. # HACK
  93. # Setting this flag to false causes imports to not load correctly in the lettuce python files
  94. # We do not yet understand why this occurs. Setting this to true is a stopgap measure
  95. USE_I18N = True
  96. # Override the test stub webpack_loader that is installed in test.py.
  97. INSTALLED_APPS = [app for app in INSTALLED_APPS if app != 'openedx.tests.util.webpack_loader']
  98. INSTALLED_APPS.append('webpack_loader')
  99. # Include the lettuce app for acceptance testing, including the 'harvest' django-admin command
  100. # django.contrib.staticfiles used to be loaded by lettuce, now we must add it ourselves
  101. # django.contrib.staticfiles is not added to lms as there is a ^/static$ route built in to the app
  102. INSTALLED_APPS.append('lettuce.django')
  103. LETTUCE_APPS = ('contentstore',)
  104. LETTUCE_BROWSER = os.environ.get('LETTUCE_BROWSER', 'chrome')
  105. # Where to run: local, saucelabs, or grid
  106. LETTUCE_SELENIUM_CLIENT = os.environ.get('LETTUCE_SELENIUM_CLIENT', 'local')
  107. SELENIUM_GRID = {
  108. 'URL': 'http://127.0.0.1:4444/wd/hub',
  109. 'BROWSER': LETTUCE_BROWSER,
  110. }
  111. #####################################################################
  112. # Lastly, see if the developer has any local overrides.
  113. try:
  114. from .private import * # pylint: disable=import-error
  115. except ImportError:
  116. pass
  117. # Point the URL used to test YouTube availability to our stub YouTube server
  118. YOUTUBE['API'] = "http://127.0.0.1:{0}/get_youtube_api/".format(YOUTUBE_PORT)
  119. YOUTUBE['METADATA_URL'] = "http://127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
  120. YOUTUBE['TEXT_API']['url'] = "127.0.0.1:{0}/test_transcripts_youtube/".format(YOUTUBE_PORT)
  121. YOUTUBE['TEST_TIMEOUT'] = 1500
  122. # Generate a random UUID so that different runs of acceptance tests don't break each other
  123. import uuid
  124. SECRET_KEY = uuid.uuid4().hex
  125. ############################### PIPELINE #######################################
  126. PIPELINE_ENABLED = False