-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: readd fragment as passthrough to webfragement.fragment (#739)
a previous deprecation of this pass-through causes wide-spread consequences.
- Loading branch information
1 parent
4b8775c
commit 2ae4557
Showing
4 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
XBlock Courseware Components | ||
""" | ||
|
||
__version__ = '3.1.0' | ||
__version__ = '4.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Makes the Fragment class available through the old namespace location. | ||
""" | ||
import warnings | ||
|
||
import web_fragments.fragment | ||
|
||
|
||
class Fragment(web_fragments.fragment.Fragment): | ||
""" | ||
A wrapper around web_fragments.fragment.Fragment that provides | ||
backwards compatibility for the old location. | ||
Deprecated. | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
warnings.warn( | ||
'xblock.fragment is deprecated. Please use web_fragments.fragment instead', | ||
DeprecationWarning, | ||
stacklevel=2 | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
# Provide older names for renamed methods | ||
add_frag_resources = web_fragments.fragment.Fragment.add_fragment_resources | ||
add_frags_resources = web_fragments.fragment.Fragment.add_resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Unit tests for the Fragment class. | ||
Note: this class has been deprecated in favor of web_fragments.fragment.Fragment | ||
""" | ||
from unittest import TestCase | ||
|
||
from xblock.fragment import Fragment | ||
|
||
|
||
class TestFragment(TestCase): | ||
""" | ||
Unit tests for fragments. | ||
""" | ||
def test_fragment(self): | ||
""" | ||
Test the delegated Fragment class. | ||
""" | ||
TEST_HTML = '<p>Hello, world!</p>' # pylint: disable=invalid-name | ||
fragment = Fragment() | ||
fragment.add_content(TEST_HTML) | ||
self.assertEqual(fragment.body_html(), TEST_HTML) |