Skip to content

Commit

Permalink
chore: Add change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Jun 20, 2024
1 parent 231ee7f commit d980494
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/xblock-tutorial/getting_started/prereqs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Python 3.11
***********

To run the a virtual environment and the XBlock SDK, and to build an XBlock,
you must have Python 3.1 installed on your computer.
you must have Python 3.11 installed on your computer.

`Download Python`_ for your operating system and follow the installation
instructions.
Expand Down
4 changes: 2 additions & 2 deletions xblock/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def open_local_resource(cls, uri):
if "/." in uri:
raise DisallowedFileError("Only safe file names are allowed: %r" % uri)

return cls.open_resource(uri)
return cls._open_resource(uri)

@classmethod
def open_resource(cls, uri):
def _open_resource(cls, uri):
return importlib.resources.files(inspect.getmodule(cls).__package__).joinpath(

Check warning on line 164 in xblock/core.py

View check run for this annotation

Codecov / codecov/patch

xblock/core.py#L164

Added line #L164 was not covered by tests
os.path.join(cls.resources_dir, uri)
).open('rb')
Expand Down
12 changes: 6 additions & 6 deletions xblock/test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ class UnloadableXBlock(XBlock):
resources_dir = None

def stub_open_resource(self, uri):
"""Act like xblock.core.Blocklike.open_resource, for testing."""
"""Act like xblock.core.Blocklike._open_resource, for testing."""
return "!" + uri + "!"

@ddt.data(
Expand All @@ -975,7 +975,7 @@ def stub_open_resource(self, uri):
)
def test_open_good_local_resource(self, uri):
loadable = self.LoadableXBlock(None, scope_ids=Mock())
with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource):
with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource):
assert loadable.open_local_resource(uri) == "!" + uri + "!"
assert loadable.open_local_resource(uri.encode('utf-8')) == "!" + uri + "!"

Expand All @@ -989,7 +989,7 @@ def test_open_good_local_resource(self, uri):
)
def test_open_good_local_resource_binary(self, uri):
loadable = self.LoadableXBlock(None, scope_ids=Mock())
with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource):
with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource):
assert loadable.open_local_resource(uri) == "!" + uri.decode('utf-8') + "!"

@ddt.data(
Expand All @@ -1003,7 +1003,7 @@ def test_open_good_local_resource_binary(self, uri):
)
def test_open_bad_local_resource(self, uri):
loadable = self.LoadableXBlock(None, scope_ids=Mock())
with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource):
with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource):
msg_pattern = ".*: %s" % re.escape(repr(uri))
with pytest.raises(DisallowedFileError, match=msg_pattern):
loadable.open_local_resource(uri)
Expand All @@ -1019,7 +1019,7 @@ def test_open_bad_local_resource(self, uri):
)
def test_open_bad_local_resource_binary(self, uri):
loadable = self.LoadableXBlock(None, scope_ids=Mock())
with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource):
with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource):
msg = ".*: %s" % re.escape(repr(uri.decode('utf-8')))
with pytest.raises(DisallowedFileError, match=msg):
loadable.open_local_resource(uri)
Expand All @@ -1042,7 +1042,7 @@ def test_open_bad_local_resource_binary(self, uri):
def test_open_local_resource_with_no_resources_dir(self, uri):
unloadable = self.UnloadableXBlock(None, scope_ids=Mock())

with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource):
with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource):
msg = "not configured to serve local resources"
with pytest.raises(DisallowedFileError, match=msg):
unloadable.open_local_resource(uri)
Expand Down

0 comments on commit d980494

Please sign in to comment.