Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions common/lib/xmodule/xmodule/modulestore/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from path import path

# from ~/mitx_all/mitx/common/lib/xmodule/xmodule/modulestore/tests/
# to ~/mitx_all/mitx/common/test
TEST_DIR = path(__file__).abspath().dirname()
for i in range(5):
TEST_DIR = TEST_DIR.dirname()
TEST_DIR = TEST_DIR / 'test'

DATA_DIR = TEST_DIR / 'data'
10 changes: 5 additions & 5 deletions common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import pymongo
from pprint import pprint

from nose.tools import assert_equals, assert_raises, assert_not_equals, assert_false
from pprint import pprint
import pymongo
from uuid import uuid4

from xblock.core import Scope
from xblock.runtime import KeyValueStore, InvalidScopeError

from xmodule.tests import DATA_DIR
from xmodule.modulestore import Location
from xmodule.modulestore.mongo import MongoModuleStore, MongoKeyValueStore
from xmodule.modulestore.xml_importer import import_from_xml

from .test_modulestore import check_path_to_location
from . import DATA_DIR
from uuid import uuid4
from xmodule.modulestore.tests.test_modulestore import check_path_to_location


HOST = 'localhost'
Expand Down
8 changes: 4 additions & 4 deletions common/lib/xmodule/xmodule/modulestore/tests/test_xml.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os.path

from nose.tools import assert_raises

from xmodule.course_module import CourseDescriptor
from xmodule.modulestore.xml import XMLModuleStore

from nose.tools import assert_raises

from .test_modulestore import check_path_to_location
from . import DATA_DIR
from xmodule.tests import DATA_DIR
from xmodule.modulestore.tests.test_modulestore import check_path_to_location


class TestXMLModuleStore(object):
Expand Down
Empty file.
12 changes: 9 additions & 3 deletions common/lib/xmodule/xmodule/modulestore/xml_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
Export all modules from `modulestore` and content from `contentstore` as xml to `root_dir`.

`modulestore`: A `ModuleStore` object that is the source of the modules to export
`contentstore`: A `ContentStore` object that is the source of the content to export
`contentstore`: A `ContentStore` object that is the source of the content to export, can be None
`course_location`: The `Location` of the `CourseModuleDescriptor` to export
`root_dir`: The directory to write the exported xml to
`course_dir`: The name of the directory inside `root_dir` to write the course content to
`draft_modulestore`: An optional `DraftModuleStore` that contains draft content, which will be exported
alongside the public content in the course.
"""

course = modulestore.get_item(course_location)
# we use get_instance instead of get_item to support modulestores
# that can't guarantee that definitions are unique
course = modulestore.get_instance(
course_location.course_id,
course_location
)

fs = OSFS(root_dir)
export_fs = fs.makeopendir(course_dir)
Expand All @@ -56,7 +61,8 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
course_xml.write(xml)

# export the static assets
contentstore.export_all_for_course(course_location, root_dir + '/' + course_dir + '/static/')
if contentstore:
contentstore.export_all_for_course(course_location, root_dir + '/' + course_dir + '/static/')

# export the static tabs
export_extra_content(export_fs, modulestore, course_location, 'static_tab', 'tabs', '.html')
Expand Down
21 changes: 13 additions & 8 deletions common/lib/xmodule/xmodule/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@

"""

import unittest
import json
import os
import unittest

import fs
import fs.osfs

import numpy

import json
from mock import Mock
from path import path

import calc
import xmodule
from xmodule.x_module import ModuleSystem
from mock import Mock
from xmodule.x_module import ModuleSystem, XModuleDescriptor


# Location of common test DATA directory
# '../../../../edx-platform/common/test/data/'
MODULE_DIR = path(__file__).dirname()
DATA_DIR = path.joinpath(*MODULE_DIR.splitall()[:-4]) / 'test/data/'


open_ended_grading_interface = {
Expand Down Expand Up @@ -67,7 +72,7 @@ def setUp(self):
pass

def test_load_class(self):
vc = xmodule.x_module.XModuleDescriptor.load_class('video')
vc = XModuleDescriptor.load_class('video')
vc_str = "<class 'xmodule.video_module.VideoDescriptor'>"
self.assertEqual(str(vc), vc_str)

Expand Down
35 changes: 16 additions & 19 deletions common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
"""
Tests for the various pieces of the CombinedOpenEndedGrading system

OpenEndedChild
OpenEndedModule

"""

from datetime import datetime
import json
from mock import Mock, MagicMock, ANY
import logging
import unittest

from test_util_open_ended import MockQueryDict, DummyModulestore
from lxml import etree
from mock import Mock, MagicMock, ANY
from pytz import UTC

from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild
from xmodule.open_ended_grading_classes.open_ended_module import OpenEndedModule
from xmodule.open_ended_grading_classes.combined_open_ended_modulev1 import CombinedOpenEndedV1Module
from xmodule.open_ended_grading_classes.grading_service_module import GradingServiceError
from xmodule.combined_open_ended_module import CombinedOpenEndedModule
from xmodule.modulestore import Location

from lxml import etree
from xmodule.tests import get_test_system, test_util_open_ended
from xmodule.tests.test_util_open_ended import MockQueryDict, DummyModulestore
import capa.xqueue_interface as xqueue_interface
from datetime import datetime
from pytz import UTC
import logging

log = logging.getLogger(__name__)

from . import get_test_system
log = logging.getLogger(__name__)

ORG = 'edX'
COURSE = 'open_ended' # name of directory with course data

import test_util_open_ended

"""
Tests for the various pieces of the CombinedOpenEndedGrading system

OpenEndedChild
OpenEndedModule

"""


class OpenEndedChildTest(unittest.TestCase):
"""
Expand Down
7 changes: 3 additions & 4 deletions common/lib/xmodule/xmodule/tests/test_conditional.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@

from ast import literal_eval
import json
import unittest

from fs.memoryfs import MemoryFS
from ast import literal_eval
from mock import Mock, patch

from xmodule.error_module import NonStaffErrorDescriptor
from xmodule.modulestore import Location
from xmodule.modulestore.xml import ImportSystem, XMLModuleStore
from xmodule.conditional_module import ConditionalModule
from xmodule.tests import DATA_DIR, get_test_system

from xmodule.tests.test_export import DATA_DIR

ORG = 'test_org'
COURSE = 'conditional' # name of directory with course data

from . import get_test_system


class DummySystem(ImportSystem):

Expand Down
21 changes: 6 additions & 15 deletions common/lib/xmodule/xmodule/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@
Tests of XML export
"""

from datetime import datetime, timedelta, tzinfo
from tempfile import mkdtemp
import unittest
import pytz
import shutil

from datetime import datetime, timedelta, tzinfo
import pytz
from fs.osfs import OSFS
from path import path
from tempfile import mkdtemp
import shutil

from xmodule.modulestore import Location
from xmodule.modulestore.xml import XMLModuleStore
from xmodule.modulestore.xml_exporter import EdxJSONEncoder

from xmodule.modulestore import Location

# from ~/mitx_all/mitx/common/lib/xmodule/xmodule/tests/
# to ~/mitx_all/mitx/common/test
TEST_DIR = path(__file__).abspath().dirname()
for i in range(4):
TEST_DIR = TEST_DIR.dirname()
TEST_DIR = TEST_DIR / 'test'

DATA_DIR = TEST_DIR / 'data'
from xmodule.tests import DATA_DIR


def strip_filenames(descriptor):
Expand Down
9 changes: 5 additions & 4 deletions common/lib/xmodule/xmodule/tests/test_import.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# -*- coding: utf-8 -*-

import datetime
import unittest
from fs.memoryfs import MemoryFS

from fs.memoryfs import MemoryFS
from lxml import etree
from mock import Mock, patch

from django.utils.timezone import UTC

from xmodule.xml_module import is_pointer_tag
from xmodule.modulestore import Location
from xmodule.modulestore.xml import ImportSystem, XMLModuleStore
from xmodule.modulestore.inheritance import compute_inherited_metadata
from xmodule.fields import Date
from xmodule.tests import DATA_DIR

from .test_export import DATA_DIR
import datetime
from django.utils.timezone import UTC

ORG = 'test_org'
COURSE = 'test_course'
Expand Down
5 changes: 2 additions & 3 deletions common/lib/xmodule/xmodule/tests/test_util_open_ended.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .import get_test_system
from xmodule.modulestore import Location
from xmodule.modulestore.xml import XMLModuleStore
from xmodule.tests.test_export import DATA_DIR
from xmodule.tests import DATA_DIR, get_test_system

OPEN_ENDED_GRADING_INTERFACE = {
'url': 'blah/',
Expand Down Expand Up @@ -42,7 +41,7 @@ class DummyModulestore(object):
def setup_modulestore(self, name):
self.modulestore = XMLModuleStore(DATA_DIR, course_dirs=[name])

def get_course(self, name):
def get_course(self, _):
"""Get a test course by directory name. If there's more than one, error."""
courses = self.modulestore.get_courses()
return courses[0]
Expand Down