Esempio n. 1
0
    def build(self):
        """
        A contextmanager that returns a MongoContentStore, and deletes its contents
        when the context closes.
        """
        contentstore = MongoContentStore(db='contentstore{}'.format(
            random.randint(0, 10000)),
                                         collection='content',
                                         **COMMON_DOCSTORE_CONFIG)
        contentstore.ensure_indexes()

        try:
            yield contentstore
        finally:
            # Delete the created database
            contentstore._drop_database()
Esempio n. 2
0
File: utils.py Progetto: saadow123/1
    def build(self):
        """
        A contextmanager that returns a MongoContentStore, and deletes its contents
        when the context closes.
        """
        contentstore = MongoContentStore(
            db='contentstore{}'.format(THIS_UUID),
            collection='content',
            **COMMON_DOCSTORE_CONFIG
        )
        contentstore.ensure_indexes()

        try:
            yield contentstore
        finally:
            # Delete the created database
            contentstore._drop_database()  # pylint: disable=protected-access
Esempio n. 3
0
    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,)

        )
        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
Esempio n. 4
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)
        # 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
Esempio n. 5
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,
                                 xblock_mixins=(XModuleMixin, ))
        # 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