Пример #1
0
def test_scope_key():
    # Tests field display name default values
    class TestBlock(XBlock):
        """
        Block for testing
        """
        field_x = List(scope=Scope.settings, name='')
        settings_lst = List(scope=Scope.settings, name='')
        uss_lst = List(scope=Scope.user_state_summary, name='')
        user_lst = List(scope=Scope.user_state, name='')
        pref_lst = List(scope=Scope.preferences, name='')
        user_info_lst = List(scope=Scope.user_info, name='')

    sids = ScopeIds(user_id="_bob",
                    block_type="b.12#ob",
                    def_id="..",
                    usage_id="..")

    field_data = DictFieldData({})

    runtime = TestRuntime(Mock(), services={'field-data': field_data})
    block = TestBlock(runtime, None, sids)

    # Format: usage or block ID/field_name/user_id
    for item, correct_key in [[TestBlock.field_x, "__..../field__x/NONE.NONE"],
                              [TestBlock.user_info_lst, "NONE.NONE/user__info__lst/____bob"],
                              [TestBlock.pref_lst, "b..12_35_ob/pref__lst/____bob"],
                              [TestBlock.user_lst, "__..../user__lst/____bob"],
                              [TestBlock.uss_lst, "__..../uss__lst/NONE.NONE"],
                              [TestBlock.settings_lst, "__..../settings__lst/NONE.NONE"]]:
        key = scope_key(item, block)
        assert_equals(key, correct_key)
Пример #2
0
def test_scope_key():
    # Tests field display name default values
    class TestBlock(XBlock):
        """
        Block for testing
        """
        field_x = List(scope=Scope.settings, name='')
        settings_lst = List(scope=Scope.settings, name='')
        uss_lst = List(scope=Scope.user_state_summary, name='')
        user_lst = List(scope=Scope.user_state, name='')
        pref_lst = List(scope=Scope.preferences, name='')
        user_info_lst = List(scope=Scope.user_info, name='')

    sids = ScopeIds(user_id="_bob",
                    block_type="b.12#ob",
                    def_id="..",
                    usage_id="..")

    field_data = DictFieldData({})

    runtime = TestRuntime(Mock(), services={'field-data': field_data})
    block = TestBlock(runtime, None, sids)

    # Format: usage or block ID/field_name/user_id
    for item, correct_key in [
        [TestBlock.field_x, "__..../field__x/NONE.NONE"],
        [TestBlock.user_info_lst, "NONE.NONE/user__info__lst/____bob"],
        [TestBlock.pref_lst, "b..12_35_ob/pref__lst/____bob"],
        [TestBlock.user_lst, "__..../user__lst/____bob"],
        [TestBlock.uss_lst, "__..../uss__lst/NONE.NONE"],
        [TestBlock.settings_lst, "__..../settings__lst/NONE.NONE"]
    ]:
        key = scope_key(item, block)
        assert_equals(key, correct_key)
Пример #3
0
 def load(self, instance, xblock):
     """
     Get the filesystem for the field specified in 'instance' and the xblock in 'xblock'
     It is locally scoped.
     """
     # TODO: Get xblock from context, once the plumbing is piped through
     return djpyfs.get_filesystem(scope_key(instance, xblock))
Пример #4
0
 def load(self, instance, xblock):
     """
     Get the filesystem for the field specified in 'instance' and the xblock in 'xblock'
     It is locally scoped.
     """
     # TODO: Get xblock from context, once the plumbing is piped through
     return djpyfs.get_filesystem(scope_key(instance, xblock))
Пример #5
0
    def load(self, instance, xblock):
        """
        Get the filesystem for the field specified in 'instance' and the
        xblock in 'xblock' It is locally scoped.
        """

        # TODO: Get xblock from context, once the plumbing is piped through
        if djpyfs:
            return djpyfs.get_filesystem(scope_key(instance, xblock))
        else:
            # The reference implementation relies on djpyfs
            # https://github.com/edx/django-pyfs
            # For Django runtimes, you may use this reference
            # implementation. Otherwise, you will need to
            # patch pyfilesystem yourself to implement get_url.
            raise NotImplementedError("djpyfs not available")