Skip to content
Snippets Groups Projects
Commit 57ecda7f authored by Nimisha Asthagiri's avatar Nimisha Asthagiri
Browse files

Remove CourseStructure usage in CourseGraph

parent 4bd30331
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ from .tasks import update_course_in_cache_v2
@receiver(SignalHandler.course_published)
def _update_block_structure_on_course_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument
def update_block_structure_on_course_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument
"""
Catches the signal that a course has been published in the module
store and creates/updates the corresponding cache entry.
......
......@@ -11,7 +11,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from ..api import get_block_structure_manager
from ..config import INVALIDATE_CACHE_ON_PUBLISH, waffle
from ..signals import _update_block_structure_on_course_publish
from ..signals import update_block_structure_on_course_publish
from .helpers import is_course_in_block_structure_cache
......@@ -78,5 +78,5 @@ class CourseBlocksSignalTest(ModuleStoreTestCase):
@ddt.unpack
@patch('openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache_v2.apply_async')
def test_update_only_for_courses(self, key, expect_update_called, mock_update):
_update_block_structure_on_course_publish(sender=None, course_key=key)
update_block_structure_on_course_publish(sender=None, course_key=key)
self.assertEqual(mock_update.called, expect_update_called)
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment