Beispiel #1
0
 def test_identical_olx(self):
     """
     Test library blocks with children that also have identical OLX. Since
     the blockstore runtime caches authored field data based on the hash of
     the OLX, this can catch some potential bugs, especially given that the
     "children" field stores usage IDs, not definition IDs.
     """
     # Create a unit containing a <problem>
     unit_block_key = library_api.create_library_block(self.library.key, "unit", "u1").usage_key
     library_api.create_library_block_child(unit_block_key, "problem", "p1")
     library_api.publish_changes(self.library.key)
     # Now do the same in a different library:
     library2 = library_api.create_library(
         collection_uuid=self.collection.uuid,
         org=self.organization,
         slug="idolx",
         title=("Identical OLX Test Lib 2"),
         description="",
         library_type=COMPLEX,
         allow_public_learning=True,
         allow_public_read=False,
         library_license=CC_4_BY,
     )
     unit_block2_key = library_api.create_library_block(library2.key, "unit", "u1").usage_key
     library_api.create_library_block_child(unit_block2_key, "problem", "p1")
     library_api.publish_changes(library2.key)
     # Load both blocks:
     unit_block = xblock_api.load_block(unit_block_key, self.student_a)
     unit_block2 = xblock_api.load_block(unit_block2_key, self.student_a)
     assert library_api.get_library_block_olx(unit_block_key) == library_api.get_library_block_olx(unit_block2_key)
     assert unit_block.children != unit_block2.children
Beispiel #2
0
 def get(self, request, usage_key_str):
     """
     Get the block's OLX
     """
     key = LibraryUsageLocatorV2.from_string(usage_key_str)
     api.require_permission_for_library_key(key.lib_key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY)
     xml_str = api.get_library_block_olx(key)
     return Response(LibraryXBlockOlxSerializer({"olx": xml_str}).data)