Пример #1
0
 def test_mongo_modulestore_type(self):
     store = DraftModuleStore(
         None,
         {'host': HOST, 'db': DB, 'port': PORT, 'collection': COLLECTION},
         FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS
     )
     assert_equals(store.get_modulestore_type(''), ModuleStoreEnum.Type.mongo)
Пример #2
0
 def test_mongo_modulestore_type(self):
     store = DraftModuleStore(
         None,
         {'host': HOST, 'db': DB, 'port': PORT, 'collection': COLLECTION},
         FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS
     )
     assert_equals(store.get_modulestore_type(''), ModuleStoreEnum.Type.mongo)
Пример #3
0
 def test_mongo_modulestore_type(self):
     store = DraftModuleStore(
         None,
         {"host": HOST, "db": DB, "port": PORT, "collection": COLLECTION},
         FS_ROOT,
         RENDER_TEMPLATE,
         default_class=DEFAULT_CLASS,
     )
     assert_equals(store.get_modulestore_type(""), ModuleStoreEnum.Type.mongo)
Пример #4
0
    def initdb():
        # connect to the db
        store = MongoModuleStore(HOST, DB, COLLECTION, FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS)
        # since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
        # as well
        content_store = MongoContentStore(HOST, DB)
        #
        # Also test draft store imports
        #
        draft_store = DraftModuleStore(HOST, DB, COLLECTION, FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS)
        # Explicitly list the courses to load (don't want the big one)
        courses = ['toy', 'simple', 'simple_with_draft', 'test_unicode']
        import_from_xml(store, DATA_DIR, courses, draft_store=draft_store, static_content_store=content_store)

        # also test a course with no importing of static content
        import_from_xml(
            store,
            DATA_DIR,
            ['test_import_course'],
            static_content_store=content_store,
            do_import_static=False,
            verbose=True
        )

        return store, content_store, draft_store
Пример #5
0
    def initdb(cls):
        # connect to the db
        doc_store_config = {
            'host': HOST,
            'db': DB,
            'collection': COLLECTION,
        }
        # since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
        # as well
        content_store = MongoContentStore(HOST, DB)
        #
        # Also test draft store imports
        #
        draft_store = DraftModuleStore(
            content_store,
            doc_store_config,
            FS_ROOT,
            RENDER_TEMPLATE,
            default_class=DEFAULT_CLASS,
            branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred)
        import_from_xml(draft_store,
                        999,
                        DATA_DIR,
                        cls.courses,
                        static_content_store=content_store)

        # also test a course with no importing of static content
        import_from_xml(draft_store,
                        999,
                        DATA_DIR, ['test_import_course'],
                        static_content_store=content_store,
                        do_import_static=False,
                        verbose=True)

        return content_store, draft_store
Пример #6
0
    def initdb():
        # connect to the db
        doc_store_config = {
            'host': HOST,
            'db': DB,
            'collection': COLLECTION,
        }
        store = MongoModuleStore(doc_store_config, FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS)
        # since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
        # as well
        content_store = MongoContentStore(HOST, DB)
        #
        # Also test draft store imports
        #
        draft_store = DraftModuleStore(doc_store_config, FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS)
        import_from_xml(store, DATA_DIR, TestMongoModuleStore.courses, draft_store=draft_store, static_content_store=content_store)

        # also test a course with no importing of static content
        import_from_xml(
            store,
            DATA_DIR,
            ['test_import_course'],
            static_content_store=content_store,
            do_import_static=False,
            verbose=True
        )

        return store, content_store, draft_store
Пример #7
0
    def initdb(cls):  # lint-amnesty, pylint: disable=missing-function-docstring
        # connect to the db
        doc_store_config = {
            'host': HOST,
            'port': PORT,
            'db': DB,
            'collection': COLLECTION,
        }
        cls.add_asset_collection(doc_store_config)

        # since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
        # as well
        content_store = MongoContentStore(HOST, DB, port=PORT)
        #
        # Also test draft store imports
        #
        draft_store = DraftModuleStore(
            content_store,
            doc_store_config,
            FS_ROOT,
            RENDER_TEMPLATE,
            default_class=DEFAULT_CLASS,
            branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,
            xblock_mixins=(EditInfoMixin, InheritanceMixin, LocationMixin,
                           XModuleMixin))

        import_course_from_xml(draft_store,
                               999,
                               DATA_DIR,
                               cls.courses,
                               static_content_store=content_store)

        # also test a course with no importing of static content
        import_course_from_xml(draft_store,
                               999,
                               DATA_DIR, ['test_import_course'],
                               static_content_store=content_store,
                               do_import_static=False,
                               verbose=True)

        # also import a course under a different course_id (especially ORG)
        import_course_from_xml(
            draft_store,
            999,
            DATA_DIR, ['test_import_course'],
            static_content_store=content_store,
            do_import_static=False,
            verbose=True,
            target_id=CourseKey.from_string('guestx/foo/bar'))

        # Import a course for `test_reference_converters` since it manipulates the saved course
        # which can cause any other test using the same course to have a flakey error
        import_course_from_xml(draft_store,
                               999,
                               DATA_DIR, ['test_import_course_2'],
                               static_content_store=content_store)

        return content_store, draft_store
    def initdb(cls):
        # connect to the db
        doc_store_config = {
            'host': HOST,
            'port': PORT,
            'db': DB,
            'collection': COLLECTION,
        }
        cls.add_asset_collection(doc_store_config)

        # since MongoModuleStore and MongoContentStore are basically assumed to be together, create this class
        # as well
        content_store = MongoContentStore(HOST, DB, port=PORT)
        #
        # Also test draft store imports
        #
        draft_store = DraftModuleStore(
            content_store,
            doc_store_config, FS_ROOT, RENDER_TEMPLATE,
            default_class=DEFAULT_CLASS,
            branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,
            xblock_mixins=(EditInfoMixin, InheritanceMixin, LocationMixin, XModuleMixin)

        )

        with patch('xmodule.tabs.CourseTab.from_json', side_effect=mock_tab_from_json):
            import_course_from_xml(
                draft_store,
                999,
                DATA_DIR,
                cls.courses,
                static_content_store=content_store
            )

            # also test a course with no importing of static content
            import_course_from_xml(
                draft_store,
                999,
                DATA_DIR,
                ['test_import_course'],
                static_content_store=content_store,
                do_import_static=False,
                verbose=True
            )

            # also import a course under a different course_id (especially ORG)
            import_course_from_xml(
                draft_store,
                999,
                DATA_DIR,
                ['test_import_course'],
                static_content_store=content_store,
                do_import_static=False,
                verbose=True,
                target_id=CourseKey.from_string('guestx/foo/bar')
            )

        return content_store, draft_store