Remove CourseStructure usage in CourseGraph

This commit is contained in:
Nimisha Asthagiri
2018-04-12 15:23:27 -04:00
parent 4bd3033185
commit 57ecda7f71
4 changed files with 19 additions and 9 deletions

View File

@@ -13,6 +13,8 @@ from django.utils import six
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j import (
ModuleStoreSerializer
)
@@ -27,9 +29,10 @@ from openedx.core.djangoapps.coursegraph.tasks import (
should_dump_course,
strip_branch_and_version,
)
from openedx.core.djangoapps.content.course_structures.signals import (
listen_for_course_publish
from openedx.core.djangoapps.content.block_structure.signals import (
update_block_structure_on_course_publish
)
import openedx.core.djangoapps.content.block_structure.config as block_structure_config
class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
@@ -226,6 +229,7 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
)
@skip_unless_lms
@ddt.ddt
class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
"""
@@ -492,7 +496,8 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
self.assertEqual(len(submitted), len(self.course_strings))
# simulate one of the courses being published
listen_for_course_publish(None, self.course.id)
with block_structure_config.waffle().override(block_structure_config.STORAGE_BACKING_FOR_CACHE):
update_block_structure_on_course_publish(None, self.course.id)
# make sure only the published course was dumped
submitted, __ = self.mss.dump_courses_to_neo4j(mock_credentials)

View File

@@ -135,11 +135,16 @@ def get_course_last_published(course_key):
was published.
"""
# Import is placed here to avoid model import at project startup.
from openedx.core.djangoapps.content.course_structures.models import CourseStructure
from xmodule.modulestore.django import modulestore
from openedx.core.djangoapps.content.block_structure.models import BlockStructureModel
from openedx.core.djangoapps.content.block_structure.exceptions import BlockStructureNotFound
store = modulestore()
course_usage_key = store.make_course_usage_key(course_key)
try:
structure = CourseStructure.objects.get(course_id=course_key)
structure = BlockStructureModel.get(course_usage_key)
course_last_published_date = six.text_type(structure.modified)
except CourseStructure.DoesNotExist:
except BlockStructureNotFound:
course_last_published_date = None
return course_last_published_date