55
66import datetime
77import json
8- from unittest import SkipTest , mock , skip
8+ from unittest import mock , skip
99from unittest .mock import patch
1010
1111import ddt
3535from openedx .core .djangoapps .waffle_utils .testutils import WAFFLE_TABLES
3636from xmodule .modulestore .django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
3737from xmodule .modulestore .exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order
38+ from xmodule .modulestore .tests .django_utils import TEST_DATA_SPLIT_MODULESTORE
3839from xmodule .modulestore .tests .factories import CourseFactory , BlockFactory , LibraryFactory , check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order
3940
4041from ..course import _deprecated_blocks_info , course_outline_initial_state , reindex_course_and_check_access
@@ -46,6 +47,8 @@ class TestCourseIndex(CourseTestCase):
4647 Unit tests for getting the list of courses and the course outline.
4748 """
4849
50+ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
51+
4952 def setUp (self ):
5053 """
5154 Add a course with odd characters in the fields
@@ -333,6 +336,9 @@ class TestCourseIndexArchived(CourseTestCase):
333336 """
334337 Unit tests for testing the course index list when there are archived courses.
335338 """
339+
340+ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
341+
336342 NOW = datetime .datetime .now (pytz .utc )
337343 DAY = datetime .timedelta (days = 1 )
338344 YESTERDAY = NOW - DAY
@@ -415,16 +421,15 @@ def check_index_page(self, separate_archived_courses, org):
415421 archived_course_tab = parsed_html .find_class ('archived-courses' )
416422 self .assertEqual (len (archived_course_tab ), 1 if separate_archived_courses else 0 )
417423
418- @skip ('Skip test for old mongo course' )
419424 @ddt .data (
420425 # Staff user has course staff access
421426 (True , 'staff' , None , 0 , 20 ),
422427 (False , 'staff' , None , 0 , 20 ),
423428 # Base user has global staff access
424- (True , 'user' , ORG , 1 , 20 ),
425- (False , 'user' , ORG , 1 , 20 ),
426- (True , 'user' , None , 1 , 20 ),
427- (False , 'user' , None , 1 , 20 ),
429+ (True , 'user' , ORG , 2 , 20 ),
430+ (False , 'user' , ORG , 2 , 20 ),
431+ (True , 'user' , None , 2 , 20 ),
432+ (False , 'user' , None , 2 , 20 ),
428433 )
429434 @ddt .unpack
430435 def test_separate_archived_courses (self , separate_archived_courses , username , org , mongo_queries , sql_queries ):
@@ -452,6 +457,9 @@ class TestCourseOutline(CourseTestCase):
452457 """
453458 Unit tests for the course outline.
454459 """
460+
461+ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
462+
455463 ENABLED_SIGNALS = ['course_published' ]
456464
457465 def setUp (self ):
@@ -550,14 +558,16 @@ def _create_test_data(self, course_block, create_blocks=False, publish=True, blo
550558 if create_blocks :
551559 for block_type in block_types :
552560 BlockFactory .create (
553- parent_location = self .vertical . location ,
561+ parent = self .vertical ,
554562 category = block_type ,
555563 display_name = f'{ block_type } Problem'
556564 )
557565
558566 if not publish :
559567 self .store .unpublish (self .vertical .location , self .user .id )
560568
569+ # get updated vertical
570+ self .vertical = modulestore ().get_item (self .vertical .location )
561571 course_block .advanced_modules .extend (block_types )
562572
563573 def _verify_deprecated_info (self , course_id , advanced_modules , info , deprecated_block_types ):
@@ -584,6 +594,7 @@ def _verify_deprecated_info(self, course_id, advanced_modules, info, deprecated_
584594 reverse_course_url ('advanced_settings_handler' , course_id )
585595 )
586596
597+ @skip ('OldMongo Deprecation. HiddenDescriptorWithMixins is not created for split.' )
587598 @ddt .data (
588599 [{'publish' : True }, ['notes' ]],
589600 [{'publish' : False }, ['notes' ]],
@@ -596,6 +607,9 @@ def test_verify_deprecated_warning_message(self, publish, block_types):
596607 """
597608 course_block = modulestore ().get_item (self .course .location )
598609 self ._create_test_data (course_block , create_blocks = True , block_types = block_types , publish = publish )
610+ # get updated course_block
611+ course_block = modulestore ().get_item (self .course .location )
612+
599613 info = _deprecated_blocks_info (course_block , block_types )
600614 self ._verify_deprecated_info (
601615 course_block .id ,
@@ -604,6 +618,7 @@ def test_verify_deprecated_warning_message(self, publish, block_types):
604618 block_types
605619 )
606620
621+ @skip ('OldMongo Deprecation. HiddenDescriptorWithMixins is not created for split.' )
607622 @ddt .data (
608623 (["a" , "b" , "c" ], ["a" , "b" , "c" ]),
609624 (["a" , "b" , "c" ], ["a" , "b" , "d" ]),
@@ -618,6 +633,8 @@ def test_verify_warn_only_on_enabled_blocks(self, enabled_block_types, deprecate
618633 expected_block_types = list (set (enabled_block_types ) & set (deprecated_block_types ))
619634 course_block = modulestore ().get_item (self .course .location )
620635 self ._create_test_data (course_block , create_blocks = True , block_types = enabled_block_types )
636+ # get updated course_module
637+ course_block = modulestore ().get_item (self .course .location )
621638 info = _deprecated_blocks_info (course_block , deprecated_block_types )
622639 self ._verify_deprecated_info (
623640 course_block .id ,
@@ -632,8 +649,6 @@ def test_proctoring_link_is_visible(self, mock_validate_proctoring_settings):
632649 """
633650 Test to check proctored exam settings mfe url is rendering properly
634651 """
635- if self .course .id .deprecated :
636- raise SkipTest ("Skip test for old mongo course" )
637652 mock_validate_proctoring_settings .return_value = [
638653 {
639654 'key' : 'proctoring_provider' ,
@@ -655,6 +670,9 @@ class TestCourseReIndex(CourseTestCase):
655670 """
656671 Unit tests for the course outline.
657672 """
673+
674+ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
675+
658676 SUCCESSFUL_RESPONSE = _ ("Course has been successfully reindexed." )
659677
660678 ENABLED_SIGNALS = ['course_published' ]
@@ -835,7 +853,7 @@ def test_reindex_seq_error_json_responses(self, mock_index_dictionary):
835853 with self .assertRaises (SearchIndexingError ):
836854 reindex_course_and_check_access (self .course .id , self .user )
837855
838- @mock .patch ('xmodule.modulestore.mongo.base.MongoModuleStore .get_course' )
856+ @mock .patch ('xmodule.modulestore.split_mongo.split.SplitMongoModuleStore .get_course' )
839857 def test_reindex_no_item (self , mock_get_course ):
840858 """
841859 Test system logs an error if no item found.
@@ -945,7 +963,7 @@ def test_indexing_seq_error_responses(self, mock_index_dictionary):
945963 with self .assertRaises (SearchIndexingError ):
946964 CoursewareSearchIndexer .do_course_reindex (modulestore (), self .course .id )
947965
948- @mock .patch ('xmodule.modulestore.mongo.base.MongoModuleStore .get_course' )
966+ @mock .patch ('xmodule.modulestore.split_mongo.split.SplitMongoModuleStore .get_course' )
949967 def test_indexing_no_item (self , mock_get_course ):
950968 """
951969 Test system logs an error if no item found.
0 commit comments