Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Run Python Tests and Coverage
runs-on: ubuntu-latest
strategy:
fail-fast: true
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
toxenv: [quality, docs, django42, django52]
Expand Down
6 changes: 6 additions & 0 deletions xblocks_contrib/video/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Tests for the video xblock.
"""

from unittest.mock import Mock
from xblocks_contrib.video.video import VideoBlock


VideoBlock.add_aside = Mock()
64 changes: 64 additions & 0 deletions xblocks_contrib/video/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from unittest.mock import Mock

from web_fragments.fragment import Fragment
from xblock.core import XBlockAside
from xblock.fields import Scope, String
from xblock.runtime import DictKeyValueStore, KvsFieldData, Runtime
from xblock.test.tools import TestRuntime

EXPORT_IMPORT_STATIC_DIR = 'static'
VALIDATION_MESSAGE_WARNING = "warning"


class DummyRuntime(TestRuntime, Runtime):
"""
Construct a test DummyRuntime instance.
"""

def __init__(self, render_template=None, **kwargs):
services = kwargs.setdefault('services', {})
services['field-data'] = KvsFieldData(DictKeyValueStore())
video_config_mock = Mock(name='video_config')
video_config_mock.available_translations = lambda block, transcripts_info, verify_assets=True: []
services['video_config'] = video_config_mock

# Ignore load_error_blocks as it's not supported by modern TestRuntime
kwargs.pop('load_error_blocks', None)

super().__init__(**kwargs)
self._resources_fs = Mock(name='DummyRuntime.resources_fs', root_path='.')

def parse_asides(self, node, def_id, usage_id, id_generator):
"""pull the asides out of the xml payload and instantiate them"""
aside_children = []
for child in node.iterchildren():
# get xblock-family from node
xblock_family = child.attrib.pop('xblock-family', None)
if xblock_family:
xblock_family = self._family_id_to_superclass(xblock_family)
if issubclass(xblock_family, XBlockAside):
aside_children.append(child)
# now process them & remove them from the xml payload
for child in aside_children:
self._aside_from_xml(child, def_id, usage_id)
node.remove(child)
return aside_children

@property
def resources_fs(self):
return self._resources_fs


class AsideTestType(XBlockAside):
"""
Test Aside type
"""
FRAG_CONTENT = "<p>Aside rendered</p>"

content = String(default="default_content", scope=Scope.content)
data_field = String(default="default_data", scope=Scope.settings)

@XBlockAside.aside_for('student_view')
def student_view_aside(self, block, context): # pylint: disable=unused-argument
"""Add to the student view"""
return Fragment(self.FRAG_CONTENT)
Loading
Loading