Performance enhancements for unit tests
in test_contentstore, don't load the xml course if not necessary
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""
|
||||
Test contentstore.mongo functionality
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
from uuid import uuid4
|
||||
import unittest
|
||||
|
||||
@@ -30,7 +30,7 @@ class PollFields(object):
|
||||
|
||||
voted = Boolean(help="Whether this student has voted on the poll", scope=Scope.user_state, default=False)
|
||||
poll_answer = String(help="Student answer", scope=Scope.user_state, default='')
|
||||
poll_answers = Dict(help="All possible answers for the poll fro other students", scope=Scope.user_state_summary)
|
||||
poll_answers = Dict(help="Poll answers from all students", scope=Scope.user_state_summary)
|
||||
|
||||
# List of answers, in the form {'id': 'some id', 'text': 'the answer text'}
|
||||
answers = List(help="Poll answers from xml", scope=Scope.content, default=[])
|
||||
|
||||
@@ -230,12 +230,55 @@ class ConvertExportFormat(unittest.TestCase):
|
||||
|
||||
# Expand all the test archives and store their paths.
|
||||
self.data_dir = path(__file__).realpath().parent / 'data'
|
||||
self.version0_nodrafts = self._expand_archive('Version0_nodrafts.tar.gz')
|
||||
self.version1_nodrafts = self._expand_archive('Version1_nodrafts.tar.gz')
|
||||
self.version0_drafts = self._expand_archive('Version0_drafts.tar.gz')
|
||||
self.version1_drafts = self._expand_archive('Version1_drafts.tar.gz')
|
||||
self.version1_drafts_extra_branch = self._expand_archive('Version1_drafts_extra_branch.tar.gz')
|
||||
self.no_version = self._expand_archive('NoVersionNumber.tar.gz')
|
||||
|
||||
self._version0_nodrafts = None
|
||||
self._version1_nodrafts = None
|
||||
self._version0_drafts = None
|
||||
self._version1_drafts = None
|
||||
self._version1_drafts_extra_branch = None
|
||||
self._no_version = None
|
||||
|
||||
@property
|
||||
def version0_nodrafts(self):
|
||||
"lazily expand this"
|
||||
if self._version0_nodrafts is None:
|
||||
self._version0_nodrafts = self._expand_archive('Version0_nodrafts.tar.gz')
|
||||
return self._version0_nodrafts
|
||||
|
||||
@property
|
||||
def version1_nodrafts(self):
|
||||
"lazily expand this"
|
||||
if self._version1_nodrafts is None:
|
||||
self._version1_nodrafts = self._expand_archive('Version1_nodrafts.tar.gz')
|
||||
return self._version1_nodrafts
|
||||
|
||||
@property
|
||||
def version0_drafts(self):
|
||||
"lazily expand this"
|
||||
if self._version0_drafts is None:
|
||||
self._version0_drafts = self._expand_archive('Version0_drafts.tar.gz')
|
||||
return self._version0_drafts
|
||||
|
||||
@property
|
||||
def version1_drafts(self):
|
||||
"lazily expand this"
|
||||
if self._version1_drafts is None:
|
||||
self._version1_drafts = self._expand_archive('Version1_drafts.tar.gz')
|
||||
return self._version1_drafts
|
||||
|
||||
@property
|
||||
def version1_drafts_extra_branch(self):
|
||||
"lazily expand this"
|
||||
if self._version1_drafts_extra_branch is None:
|
||||
self._version1_drafts_extra_branch = self._expand_archive('Version1_drafts_extra_branch.tar.gz')
|
||||
return self._version1_drafts_extra_branch
|
||||
|
||||
@property
|
||||
def no_version(self):
|
||||
"lazily expand this"
|
||||
if self._no_version is None:
|
||||
self._no_version = self._expand_archive('NoVersionNumber.tar.gz')
|
||||
return self._no_version
|
||||
|
||||
def tearDown(self):
|
||||
""" Common cleanup. """
|
||||
|
||||
Reference in New Issue
Block a user