Running tests that use CourseFactory.create()

Hello!

Sorry for the ignorance, I am new to the project and trying to contribute where I can.
I am looking if I can contribute to this issue.
But I am having problems running the tests (without any changes)

Using devstack.

make dev.up.large-and-slow
make cms-shell
pytest cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py

This gives me a failed test (1 failed, 3 passed, 1 skipped, 11 warnings in 4.28s):

_________________________________________________________________________________________________________________________ TestCourseExportOlx.test_export_course _________________________________________________________________________________________________________________________

self = <cms.djangoapps.contentstore.management.commands.tests.test_export_olx.TestCourseExportOlx testMethod=test_export_course>

    def test_export_course(self):
>       test_course_key = self.create_dummy_course(ModuleStoreEnum.Type.split)

cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py:59: in create_dummy_course
    course = CourseFactory.create(default_store=store_type)
../venvs/edxapp/lib/python3.8/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
../venvs/edxapp/lib/python3.8/site-packages/factory/base.py:465: in _generate
    return step.build()
../venvs/edxapp/lib/python3.8/site-packages/factory/builder.py:274: in build
    instance = self.factory_meta.instantiate(
../venvs/edxapp/lib/python3.8/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
xmodule/modulestore/tests/factories.py:145: in _create
    new_course = store.create_course(org, number, run, user_id, fields=kwargs)
xmodule/modulestore/mixed.py:90: in inner
    retval = func(field_decorator=strip_key_collection, *args, **kwargs)
xmodule/modulestore/mixed.py:674: in create_course
    course = store.create_course(org, course, run, user_id, **kwargs)
xmodule/modulestore/split_mongo/split_draft.py:39: in create_course
    item = super().create_course(
xmodule/modulestore/split_mongo/split.py:1832: in create_course
    return self._create_courselike(
xmodule/modulestore/split_mongo/split.py:1849: in _create_courselike
    partitioned_fields = self.partition_fields_by_scope(root_category, fields)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore object at 0x7fa4afb621f0>, category = 'course', fields = {'display_name': 'Run 0', 'enrollment_start': None}

    def partition_fields_by_scope(self, category, fields):
        """
        Return dictionary of {scope: {field1: val, ..}..} for the fields of this potential xblock
    
        :param category: the xblock category
        :param fields: the dictionary of {fieldname: value}
        """
        result = defaultdict(dict)
        if fields is None:
            return result
        classes = XBlock.load_class(category, default=self.default_class)
        cls = self.mixologist.mix(classes)
        for field_name, value in fields.items():
>           field = getattr(cls, field_name)
E           AttributeError: type object 'HiddenBlockWithMixins' has no attribute 'enrollment_start'

xmodule/modulestore/__init__.py:1277: AttributeError

Basically, any test that I run that uses CourseFactory.create() gives me AttributeError: type object 'HiddenBlockWithMixins' has no attribute 'enrollment_start' in the same place.
I don’t know if I am missing anything.

When an XBlock cannot be loaded normally, it sometimes gets replaced with HiddenBlock. So the root issue is probably that one or more of the XBlocks used by CourseFactory is not installed properly into your python virtual environment. In this case, it can’t find the course XBlock, which is kind of an important one.

You may be able to fix it simply by running pip install -e . in your edx-platform folder. This will scan setup.py for all the XBlocks, including course. Then try again.

That was it. Thanks!