Ejemplo n.º 1
0
 def test_has_unlock_previous_false_if_none(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['unlockPrevious'] = None
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     prev_button_object = UnlockPreviousButtonAssessmentOfferedRecord(osid_object)
     self.assertFalse(prev_button_object.has_unlock_previous())
Ejemplo n.º 2
0
 def test_can_get_object_map(self):
     utcnow = datetime.datetime.utcnow()
     utcfuture = utcnow + datetime.timedelta(hours=5)
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['_id'] = 0
     obj_map['startTime'] = utcnow
     obj_map['deadline'] = utcfuture
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     review_offered_object = ReviewOptionsAssessmentOfferedRecord(
         osid_object)
     object_map = review_offered_object.object_map
     self.assertIn('startTime', object_map)
     self.assertIn('deadline', object_map)
     self.assertEqual(
         object_map['startTime'], {
             'year': utcnow.year,
             'month': utcnow.month,
             'day': utcnow.day,
             'hour': utcnow.hour,
             'minute': utcnow.minute,
             'second': utcnow.second,
             'microsecond': utcnow.microsecond
         })
     self.assertEqual(
         object_map['deadline'], {
             'year': utcfuture.year,
             'month': utcfuture.month,
             'day': utcfuture.day,
             'hour': utcfuture.hour,
             'minute': utcfuture.minute,
             'second': utcfuture.second,
             'microsecond': utcfuture.microsecond
         })
Ejemplo n.º 3
0
    def test_can_get_edxml_with_aws_urls_for_html_asset_content(self):
        markup = """
<html>
    <head>
        <script src="{0}">fake script</script>
    </head>
    <body>
        <img src="{0}" />
        <a href="{0}" />
    </body>
</html>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Ahtml%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        olx = asset_content.get_edxml_with_aws_urls()

        html_soup = BeautifulSoup(olx, 'html5lib')
        assert html_soup.html is not None
        assert '/api/v1/repository/repositories/' in html_soup.script['src']
        assert '/api/v1/repository/repositories/' in html_soup.img['src']
        assert '/api/v1/repository/repositories/' in html_soup.a['href']
Ejemplo n.º 4
0
    def test_can_export_olx_for_discussion_asset_content(self):
        markup = """
<discussion display_name="for some problem">
</discussion>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Adiscussion%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        expected_path = 'discussion/a-fake-parent.xml'

        assert expected_path not in self.tarfile.getnames()

        updated_path = asset_content.export_olx(self.tarfile, '',
                                                DummyParent())
        assert updated_path == 'discussion/a-fake-parent.xml'
        assert expected_path in self.tarfile.getnames()

        self.stream.seek(0)
        readable_tar = tarfile.open(fileobj=self.stream, mode='r')
        xml_doc = readable_tar.extractfile(expected_path)

        xml_soup = BeautifulSoup(xml_doc, 'xml')
        assert xml_soup.discussion is not None
Ejemplo n.º 5
0
    def test_can_get_edxml_with_aws_urls_for_problem_asset_content(self):
        markup = """
        <problem>
            <drag_and_drop_input img="{0}">
                <draggable icon="{0}">
                </draggable>
            </drag_and_drop_input>
        </problem>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Aproblem%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        olx = asset_content.get_edxml_with_aws_urls()

        xml_soup = BeautifulSoup(olx, 'xml')
        assert xml_soup.problem is not None
        problem = xml_soup.problem
        assert '/api/v1/repository/repositories/' in problem.draggable['icon']
        assert '/api/v1/repository/repositories/' in problem.drag_and_drop_input[
            'img']
Ejemplo n.º 6
0
    def test_can_get_edxml_with_aws_urls_for_video_asset_content(self):
        markup = """
<video sub="{0}" youtube="{0}" youtube_id_1_0="{0}">
    <encoded_video url="{0}">
    </encoded_video>
</video>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Avideo%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        olx = asset_content.get_edxml_with_aws_urls()

        xml_soup = BeautifulSoup(olx, 'xml')
        assert xml_soup.video is not None
        video = xml_soup.video
        assert '/api/v1/repository/repositories/' in video['sub']
        assert '/api/v1/repository/repositories/' in video['youtube']
        assert '/api/v1/repository/repositories/' in video['youtube_id_1_0']
        assert '/api/v1/repository/repositories/' in video.encoded_video['url']
Ejemplo n.º 7
0
    def test_can_get_filename(self):
        for genus_type in [
                'fake.Genus%3Acourse40ODL.MIT.EDU',
                'fake.Genus%3Achapter%40ODL.MIT.EDU',
                'fake.Genus%3Asequential%40ODL.MIT.EDU',
                'fake.Genus%3Avertical%40ODL.MIT.EDU',
                'fake.Genus%3Asplit_test%40ODL.MIT.EDU'
        ]:
            obj_map = deepcopy(self.obj_map)
            obj_map['texts'] = {
                'fileName': {
                    'text': 'foo-{0}.xml'.format(genus_type),
                    'languageTypeId': '639-2%3AENG%40ISO',
                    'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
                    'scriptTypeId': '15924%3ALATN%40ISO'
                }
            }
            obj_map['genusTypeId'] = genus_type

            osid_object = OsidObject(
                object_name='REPOSITORY',
                osid_object_map=obj_map,
                runtime=self.rm._provider_manager._runtime)
            composition = EdXCompositionRecord(osid_object)
            assert isinstance(composition.filename, DisplayText)
            assert composition.filename.text == 'foo-{0}.xml'.format(
                genus_type)
Ejemplo n.º 8
0
 def setUpClass(cls):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['texts'] = {
         'platform': {
             'text': 'SomeX',
             'languageTypeId': '639-2%3AENG%40ISO',
             'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
             'scriptTypeId': '15924%3ALATN%40ISO'
         },
         'gradingPolicy': {
             'text': 'Everything is worth 100 points',
             'languageTypeId': '639-2%3AENG%40ISO',
             'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
             'scriptTypeId': '15924%3ALATN%40ISO'
         },
         'policy': {
             'text': 'Stuff was due yesterday',
             'languageTypeId': '639-2%3AENG%40ISO',
             'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
             'scriptTypeId': '15924%3ALATN%40ISO'
         },
     }
     obj_map['recordTypeIds'] = ['repository-record-type%3Arun-repo%40ODL.MIT.EDU']
     cls.rm = get_repository_manager()
     cls.osid_object = OsidObject(object_name='REPOSITORY',
                                  osid_object_map=obj_map,
                                  runtime=cls.rm._provider_manager._runtime)
     cls.lore_repository = LoreCourseRunRepositoryRecord(cls.osid_object)
Ejemplo n.º 9
0
 def test_get_unlock_previous_throws_exception_if_no_unlock_previous(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     prev_button_object = UnlockPreviousButtonAssessmentOfferedRecord(osid_object)
     with self.assertRaises(errors.IllegalState):
         prev_button_object.unlock_previous
Ejemplo n.º 10
0
 def test_has_attempts_false_if_none(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['maxAttempts'] = None
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     review_offered_object = ReviewOptionsAssessmentOfferedRecord(
         osid_object)
     self.assertFalse(review_offered_object.has_max_attempts())
Ejemplo n.º 11
0
 def setUp(self):
     self.taken_object = ProvenanceAssessmentTakenRecord(self.osid_object)
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['provenanceId'] = ''
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     self.taken_object_no_provenance = ProvenanceAssessmentTakenRecord(
         osid_object)
Ejemplo n.º 12
0
 def test_can_get_max_attempts(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['maxAttempts'] = 2
     osid_object = OsidObject(object_name='TEST_OBJECT',
                              osid_object_map=obj_map)
     review_offered_object = ReviewOptionsAssessmentOfferedRecord(
         osid_object)
     self.assertEqual(review_offered_object.max_attempts, 2)
Ejemplo n.º 13
0
    def test_can_export_olx_for_html_asset_content(self):
        markup = """
<html>
    <head>
        <script src="{0}">fake script</script>
    </head>
    <body>
        <img src="{0}" />
        <a href="{0}" />
    </body>
</html>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Ahtml%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        expected_path = 'html/a-fake-parent.xml'
        expected_html_path = 'html/a-fake-parent.html'

        assert expected_path not in self.tarfile.getnames()
        assert expected_html_path not in self.tarfile.getnames()

        updated_path = asset_content.export_olx(self.tarfile, '',
                                                DummyParent())
        assert updated_path == 'html/a-fake-parent.xml'
        assert expected_path in self.tarfile.getnames()
        assert expected_html_path in self.tarfile.getnames()

        self.stream.seek(0)
        readable_tar = tarfile.open(fileobj=self.stream, mode='r')
        xml_doc = readable_tar.extractfile(expected_path)

        xml_soup = BeautifulSoup(xml_doc, 'xml')
        assert xml_soup.html is not None
        html_pointer = xml_soup.html
        assert 'display_name' in html_pointer.attrs
        assert html_pointer['display_name'] == 'my name'
        assert 'filename' in html_pointer.attrs
        assert html_pointer['filename'] == 'a-fake-parent'
        assert 'url_name' in html_pointer.attrs
        assert html_pointer['url_name'] == 'a-fake-parent'

        html_doc = readable_tar.extractfile(expected_html_path)
        html_soup = BeautifulSoup(html_doc, 'html5lib')
        assert 'display_name' in html_soup.html.attrs
        assert html_soup.html['display_name'] == 'my name'
        assert html_soup.script['src'] == '/static/stream'
        assert html_soup.img['src'] == '/static/stream'
        assert html_soup.a['href'] == '/static/stream'
Ejemplo n.º 14
0
 def test_getting_policy_if_not_present_raises_illegal_state(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['texts'] = {}
     obj_map['recordTypeIds'] = ['repository-record-type%3Arun-repo%40ODL.MIT.EDU']
     osid_object = OsidObject(object_name='REPOSITORY',
                              osid_object_map=obj_map,
                              runtime=self.rm._provider_manager._runtime)
     lore_repository = LoreCourseRunRepositoryRecord(osid_object)
     with self.assertRaises(errors.IllegalState):
         lore_repository.policy
Ejemplo n.º 15
0
 def test_getting_policy_if_not_present_raises_illegal_state(self):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['texts'] = {}
     obj_map['recordTypeIds'] = [
         'repository-composition%3Aedx-course-run%40EDX.ORG'
     ]
     osid_object = OsidObject(object_name='COMPOSITION',
                              osid_object_map=obj_map,
                              runtime=self.rm._provider_manager._runtime)
     composition = EdXCourseRunCompositionRecord(osid_object)
     with pytest.raises(errors.IllegalState):
         composition.policy
Ejemplo n.º 16
0
    def test_vertical_can_get_draft(self):
        self.obj_map['draft'] = False
        self.obj_map['genusTypeId'] = 'fake.Genus%3Avertical%40ODL.MIT.EDU'

        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=self.obj_map,
                                 runtime=self.rm._provider_manager._runtime)
        composition = EdXCompositionRecord(osid_object)

        result = composition.draft
        assert isinstance(result, bool)
        assert not result
Ejemplo n.º 17
0
    def test_can_get_learning_objective_ids(self):
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['learningObjectiveIds'] = [
            'package.One%3A1%40ODL.MIT.EDU', 'package.Two%3A2%40ODL.MIT.EDU'
        ]
        osid_object = OsidObject(object_name='ASSET_CONTENT',
                                 osid_object_map=obj_map)
        asset = edXAssetRecord(osid_object)

        result = asset.get_learning_objective_ids()
        assert isinstance(result, IdList)
        assert result.available() == 2
        assert str(next(result)) == 'package.One%3A1%40ODL.MIT.EDU'
        assert str(next(result)) == 'package.Two%3A2%40ODL.MIT.EDU'
Ejemplo n.º 18
0
 def setUpClass(cls):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['displayName'] = {
         'text': 'Fake Display Name, 123',
         'languageTypeId': '639-2%3AENG%40ISO',
         'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
         'scriptTypeId': '15924%3ALATN%40ISO'
     }
     obj_map['recordTypeIds'] = ['repository-record-type%3Alore-repo%40ODL.MIT.EDU']
     obj_map['_id'] = 'fake-id'
     rm = get_repository_manager()
     cls.osid_object = OsidObject(object_name='REPOSITORY',
                                  osid_object_map=obj_map,
                                  runtime=rm._provider_manager._runtime)
     cls.lore_repository = LoreRepositoryRecord(cls.osid_object)
Ejemplo n.º 19
0
def course_run_composition_test_fixture(request):
    obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
    obj_map['texts'] = {
        'platform': {
            'text': 'SomeX',
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        },
        'gradingPolicy': {
            'text': 'Everything is worth 100 points',
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        },
        'policy': {
            'text': 'Stuff was due yesterday',
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        },
    }
    obj_map['recordTypeIds'] = [
        'repository-record-type%3Arun-repo%40ODL.MIT.EDU'
    ]
    request.cls.rm = get_repository_manager()
    request.cls.osid_object = OsidObject(
        object_name='REPOSITORY',
        osid_object_map=obj_map,
        runtime=request.cls.rm._provider_manager._runtime)
    request.cls.composition = EdXCourseRunCompositionRecord(
        request.cls.osid_object)

    def test_tear_down():
        for repository in request.cls.rm.get_repositories():
            repository.use_unsequestered_composition_view()
            for asset in repository.get_assets():
                repository.delete_asset(asset.ident)
            while repository.get_compositions().available() > 0:
                for composition in repository.get_compositions():
                    try:
                        repository.delete_composition(composition.ident)
                    except errors.IllegalState:
                        pass
            request.cls.rm.delete_repository(repository.ident)

    request.addfinalizer(test_tear_down)
Ejemplo n.º 20
0
    def test_chapter_and_sequential_can_get_visible_to_students(self):
        for genus_type in [
                'fake.Genus%3Achapter%40ODL.MIT.EDU',
                'fake.Genus%3Asequential%40ODL.MIT.EDU'
        ]:
            self.obj_map['visibleToStudents'] = False
            self.obj_map['genusTypeId'] = genus_type

            osid_object = OsidObject(
                object_name='REPOSITORY',
                osid_object_map=self.obj_map,
                runtime=self.rm._provider_manager._runtime)
            composition = EdXCompositionRecord(osid_object)

            result = composition.visible_to_students
            assert isinstance(result, bool)
            assert not result
Ejemplo n.º 21
0
    def test_chapter_and_sequential_can_get_start_date(self):
        for genus_type in [
                'fake.Genus%3Achapter%40ODL.MIT.EDU',
                'fake.Genus%3Asequential%40ODL.MIT.EDU'
        ]:
            utcnow = DateTime.utcnow()
            self.obj_map['startDate'] = utcnow
            self.obj_map['genusTypeId'] = genus_type

            osid_object = OsidObject(
                object_name='REPOSITORY',
                osid_object_map=self.obj_map,
                runtime=self.rm._provider_manager._runtime)
            composition = EdXCompositionRecord(osid_object)

            result = composition.start_date
            assert isinstance(result, DateTime)
            assert result == utcnow
Ejemplo n.º 22
0
 def setUpClass(cls):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     obj_map['reviewOptions'] = {
         'whetherCorrect': {
             'duringAttempt': False,
             'afterAttempt': False,
             'beforeDeadline': False,
             'afterDeadline': False
         },
         'solution': {
             'duringAttempt': False,
             'afterAttempt': False,
             'beforeDeadline': False,
             'afterDeadline': False
         }
     }
     cls.osid_object = OsidObject(object_name='TEST_OBJECT',
                                  osid_object_map=obj_map)
Ejemplo n.º 23
0
    def test_split_test_can_get_user_partition_id(self):
        self.obj_map['texts'] = {
            'userPartitionId': {
                'text': '12345',
                'languageTypeId': '639-2%3AENG%40ISO',
                'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
                'scriptTypeId': '15924%3ALATN%40ISO'
            }
        }
        self.obj_map['genusTypeId'] = 'fake.Genus%3Asplit_test%40ODL.MIT.EDU'

        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=self.obj_map,
                                 runtime=self.rm._provider_manager._runtime)
        composition = EdXCompositionRecord(osid_object)

        result = composition.user_partition_id
        assert isinstance(result, DisplayText)
        assert result.text == '12345'
Ejemplo n.º 24
0
def edx_asset_content_class_fixture(request):
    obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
    request.cls.osid_object = OsidObject(object_name='TEST_OBJECT',
                                         osid_object_map=obj_map)
    request.cls.asset_content = edXAssetContentRecord(request.cls.osid_object)

    request.cls.test_file = open(
        os.path.join(ABS_PATH, '..', '..', '..', 'tests', 'fixtures', 'assets',
                     'draggable.green.dot.png'), 'rb')

    request.cls.rm = get_repository_manager()
    form = request.cls.rm.get_repository_form_for_create([])
    form.display_name = 'Test repo'
    request.cls.repo = request.cls.rm.create_repository(form)

    form = request.cls.repo.get_asset_form_for_create([])
    form.display_name = 'test asset'
    asset = request.cls.repo.create_asset(form)

    asset_content_type_list = []
    try:
        config = request.cls.repo._catalog._runtime.get_configuration()
        parameter_id = Id('parameter:assetContentRecordTypeForFiles@json')
        asset_content_type_list.append(
            config.get_value_by_parameter(parameter_id).get_type_value())
    except (AttributeError, KeyError, errors.NotFound):
        pass

    form = request.cls.repo.get_asset_content_form_for_create(
        asset.ident, asset_content_type_list)
    form.set_data(DataInputStream(request.cls.test_file))
    request.cls.repo.create_asset_content(form)

    request.cls.asset = request.cls.repo.get_asset(asset.ident)

    def class_tear_down():
        request.cls.test_file.close()
        for asset in request.cls.repo.get_assets():
            request.cls.repo.delete_asset(asset.ident)
        request.cls.rm.delete_repository(request.cls.repo.ident)

    request.addfinalizer(class_tear_down)
Ejemplo n.º 25
0
def edx_utilities_mixin_class_fixture(request):
    request.cls.mixin = EdXUtilitiesMixin()

    obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
    obj_map['displayName'] = {
        'text': 'Fake Display Name, 123',
        'languageTypeId': '639-2%3AENG%40ISO',
        'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
        'scriptTypeId': '15924%3ALATN%40ISO'
    }
    request.cls.mixin.my_osid_object = OsidObject(object_name='TEST_OBJECT',
                                                  osid_object_map=obj_map)

    request.cls.test_file = open(
        os.path.join(ABS_PATH, '..', '..', '..', 'tests', 'fixtures', 'assets',
                     'draggable.green.dot.png'), 'rb')

    def class_tear_down():
        request.cls.test_file.close()

    request.addfinalizer(class_tear_down)
Ejemplo n.º 26
0
    def test_can_export_olx_for_video_asset_content(self):
        markup = """
<video sub="{0}" youtube="{0}" youtube_id_1_0="{0}">
    <encoded_video url="{0}">
    </encoded_video>
</video>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Avideo%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        expected_path = 'video/a-fake-parent.xml'

        assert expected_path not in self.tarfile.getnames()

        updated_path = asset_content.export_olx(self.tarfile, '',
                                                DummyParent())
        assert updated_path == 'video/a-fake-parent.xml'
        assert expected_path in self.tarfile.getnames()

        self.stream.seek(0)
        readable_tar = tarfile.open(fileobj=self.stream, mode='r')
        xml_doc = readable_tar.extractfile(expected_path)

        xml_soup = BeautifulSoup(xml_doc, 'xml')
        assert xml_soup.video is not None
        video = xml_soup.video
        assert video['sub'] == '/static/stream'
        assert video['youtube'] == '/static/stream'
        assert video['youtube_id_1_0'] == '/static/stream'
        assert video.encoded_video['url'] == '/static/stream'
Ejemplo n.º 27
0
    def test_can_call_has_provenance_children_mocked(self, MockJSON_CLIENT):
        class FakeResults:
            def count(self):
                return 1

        class FakeClient(MagicMock):
            def __get_item__(self):
                return self

            def find(self, *args):
                return FakeResults()

        MockJSON_CLIENT.json_client = FakeClient()

        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        taken_id = 'taken%3A123%40ODL.MIT.EDU'
        obj_map['id'] = taken_id
        osid_object = OsidObject(object_name='TEST_OBJECT',
                                 osid_object_map=obj_map)
        taken_object = ProvenanceAssessmentTakenRecord(osid_object)

        self.assertTrue(taken_object.has_provenance_children())
Ejemplo n.º 28
0
    def test_can_get_edxml_with_aws_urls_for_discussion_asset_content(self):
        markup = """
        <discussion display_name="for some problem">
        </discussion>""".format(str(self.asset.ident))
        obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
        obj_map['text'] = {
            'text': markup,
            'languageTypeId': '639-2%3AENG%40ISO',
            'formatTypeId': 'TextFormats%3APLAIN%40okapia.net',
            'scriptTypeId': '15924%3ALATN%40ISO'
        }
        obj_map['assignedRepositoryIds'] = [str(self.repo.ident)]
        obj_map['genusTypeId'] = 'fake.Genus%3Adiscussion%40ODL.MIT.EDU'
        osid_object = OsidObject(object_name='REPOSITORY',
                                 osid_object_map=obj_map,
                                 runtime=self.repo._catalog._runtime)
        asset_content = edXAssetContentRecord(osid_object)

        olx = asset_content.get_edxml_with_aws_urls()

        xml_soup = BeautifulSoup(olx, 'xml')
        assert xml_soup.discussion is not None
Ejemplo n.º 29
0
    def test_non_course_can_get_learning_objective_ids(self):
        for genus_type in [
                'fake.Genus%3Achapter%40ODL.MIT.EDU',
                'fake.Genus%3Asequential%40ODL.MIT.EDU',
                'fake.Genus%3Avertical%40ODL.MIT.EDU',
                'fake.Genus%3Asplit_test%40ODL.MIT.EDU'
        ]:
            obj_map = deepcopy(self.obj_map)
            obj_map['learningObjectiveIds'] = [
                'package.One%3A1%40ODL.MIT.EDU',
                'package.Two%3A2%40ODL.MIT.EDU'
            ]
            obj_map['genusTypeId'] = genus_type

            osid_object = OsidObject(
                object_name='REPOSITORY',
                osid_object_map=obj_map,
                runtime=self.rm._provider_manager._runtime)
            composition = EdXCompositionRecord(osid_object)
            result = composition.learning_objective_ids
            assert isinstance(result, IdList)
            assert result.available() == 2
            assert str(next(result)) == 'package.One%3A1%40ODL.MIT.EDU'
            assert str(next(result)) == 'package.Two%3A2%40ODL.MIT.EDU'
Ejemplo n.º 30
0
 def setUpClass(cls):
     obj_map = deepcopy(utilities.TEST_OBJECT_MAP)
     cls.provenance_id = 'my-fake%3A000000000000000000000000%40ODL.MIT.EDU'
     obj_map['provenanceId'] = cls.provenance_id
     cls.osid_object = OsidObject(object_name='TEST_OBJECT',
                                  osid_object_map=obj_map)