Merge pull request #298 from edx/jonahstanley/acceptance-tests-unique-database
Jonahstanley/acceptance tests unique database
This commit is contained in:
@@ -17,6 +17,9 @@ from selenium.common.exceptions import WebDriverException
|
||||
# These names aren't used, but do important work on import.
|
||||
from lms import one_time_startup # pylint: disable=W0611
|
||||
from cms import one_time_startup # pylint: disable=W0611
|
||||
from pymongo import MongoClient
|
||||
import xmodule.modulestore.django
|
||||
from xmodule.contentstore.django import _CONTENTSTORE
|
||||
|
||||
# There is an import issue when using django-staticfiles with lettuce
|
||||
# Lettuce assumes that we are using django.contrib.staticfiles,
|
||||
@@ -87,6 +90,22 @@ def reset_data(scenario):
|
||||
LOGGER.debug("Flushing the test database...")
|
||||
call_command('flush', interactive=False)
|
||||
|
||||
|
||||
@after.each_scenario
|
||||
def reset_databases(scenario):
|
||||
'''
|
||||
After each scenario, all databases are cleared/dropped. Contentstore data are stored in unique databases
|
||||
whereas modulestore data is in unique collection names. This data is created implicitly during the scenarios.
|
||||
If no data is created during the test, these lines equivilently do nothing.
|
||||
'''
|
||||
mongo = MongoClient()
|
||||
mongo.drop_database(settings.CONTENTSTORE['OPTIONS']['db'])
|
||||
_CONTENTSTORE.clear()
|
||||
modulestore = xmodule.modulestore.django.modulestore()
|
||||
modulestore.collection.drop()
|
||||
xmodule.modulestore.django._MODULESTORES.clear()
|
||||
|
||||
|
||||
# Uncomment below to trigger a screenshot on error
|
||||
# @after.each_scenario
|
||||
def screenshot_on_error(scenario):
|
||||
|
||||
Reference in New Issue
Block a user