Commit 8a784eef by Christopher Lee Committed by GitHub

Merge pull request #13949 from edx/release-2016-11-08-conflict

Release 2016 11 08 conflict
parents 371c5a24 d3c3a9a6
......@@ -39,12 +39,14 @@ class ModuleStoreSerializer(object):
one graph per course.
"""
def __init__(self, courses=None):
def __init__(self, courses=None, skip=None):
"""
Sets the object's course_keys attribute from the `courses` parameter.
If that parameter isn't furnished, loads all course_keys from the
modulestore.
Filters out course_keys in the `skip` parameter, if provided.
:param courses: string serialization of course keys
:param skip: string serialization of course keys
"""
if courses:
course_keys = [CourseKey.from_string(course.strip()) for course in courses]
......@@ -52,6 +54,9 @@ class ModuleStoreSerializer(object):
course_keys = [
course.id for course in modulestore().get_course_summaries()
]
if skip is not None:
skip_keys = [CourseKey.from_string(course.strip()) for course in skip]
course_keys = [course_key for course_key in course_keys if course_key not in skip_keys]
self.course_keys = course_keys
@staticmethod
......@@ -281,13 +286,14 @@ class Command(BaseCommand):
--secure --user user --password password --settings=aws
"""
def add_arguments(self, parser):
parser.add_argument('--host', type=unicode)
parser.add_argument('--host', type=six.text_type)
parser.add_argument('--https_port', type=int, default=7473)
parser.add_argument('--http_port', type=int, default=7474)
parser.add_argument('--secure', action='store_true')
parser.add_argument('--user', type=unicode)
parser.add_argument('--password', type=unicode)
parser.add_argument('--courses', type=unicode, nargs='*')
parser.add_argument('--user', type=six.text_type)
parser.add_argument('--password', type=six.text_type)
parser.add_argument('--courses', type=six.text_type, nargs='*')
parser.add_argument('--skip', type=six.text_type, nargs='*')
parser.add_argument(
'--override',
action='store_true',
......@@ -322,7 +328,7 @@ class Command(BaseCommand):
secure=secure,
)
mss = ModuleStoreSerializer(options['courses'])
mss = ModuleStoreSerializer(options['courses'], options['skip'])
successful_courses, unsuccessful_courses = mss.dump_courses_to_neo4j(
graph, override_cache=options['override']
......
......@@ -52,7 +52,6 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
"""
Test that you can specify which courses you want to dump.
"""
mock_graph = mock_graph_class.return_value
mock_transaction = mock.Mock()
mock_graph.begin.return_value = mock_transaction
......@@ -71,12 +70,56 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
self.assertEqual(mock_transaction.commit.rollback.call_count, 0)
@mock.patch('openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j.Graph')
def test_dump_skip_course(self, mock_graph_class):
"""
Test that you can skip courses.
"""
mock_graph = mock_graph_class.return_value
mock_transaction = mock.Mock()
mock_graph.begin.return_value = mock_transaction
call_command(
'dump_to_neo4j',
skip=self.course_strings[:1],
host='mock_host',
http_port=7474,
user='mock_user',
password='mock_password',
)
self.assertEqual(mock_graph.begin.call_count, 1)
self.assertEqual(mock_transaction.commit.call_count, 1)
self.assertEqual(mock_transaction.commit.rollback.call_count, 0)
@mock.patch('openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j.Graph')
def test_dump_skip_beats_specifying(self, mock_graph_class):
"""
Test that if you skip and specify the same course, you'll skip it.
"""
mock_graph = mock_graph_class.return_value
mock_transaction = mock.Mock()
mock_graph.begin.return_value = mock_transaction
call_command(
'dump_to_neo4j',
skip=self.course_strings[:1],
courses=self.course_strings[:1],
host='mock_host',
http_port=7474,
user='mock_user',
password='mock_password',
)
self.assertEqual(mock_graph.begin.call_count, 0)
self.assertEqual(mock_transaction.commit.call_count, 0)
self.assertEqual(mock_transaction.commit.rollback.call_count, 0)
@mock.patch('openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j.Graph')
def test_dump_all_courses(self, mock_graph_class):
"""
Test if you don't specify which courses to dump, then you'll dump
all of them.
"""
mock_graph = mock_graph_class.return_value
mock_transaction = mock.Mock()
mock_graph.begin.return_value = mock_transaction
......
......@@ -8,7 +8,7 @@
# For Harvard courses:
-e git+https://github.com/gsehub/xblock-mentoring.git@4d1cce78dc232d5da6ffd73817b5c490e87a6eee#egg=xblock-mentoring
git+https://github.com/open-craft/problem-builder.git@v2.6.0#egg=xblock-problem-builder==2.6.0
git+https://github.com/open-craft/problem-builder.git@v2.0.4#egg=xblock-problem-builder==2.0.4
# Oppia XBlock
-e git+https://github.com/oppia/xblock.git@9f6b95b7eb7dbabb96b77198a3202604f96adf65#egg=oppia-xblock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment