-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: deserialize tag info from xml [FC-0049] #2181
feat: deserialize tag info from xml [FC-0049] #2181
Conversation
Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
# Deserialize and add tag data info to block if any | ||
if hasattr(block, 'read_tags_from_node') and callable(block.read_tags_from_node): # pylint: disable=no-member | ||
# This comes from TaggedBlockMixin | ||
block.read_tags_from_node(node) # pylint: disable=no-member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as expected manual testing in the edx-platform
, but in the tests here, it fails. I think it is because this block doesn't have the XmlMixin. As it is a new dependency, I'm unsure if I should add it here or find another way to test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I faced similar issues when implementing the copy functionality. Since we don't have access to the XBLOCK_MIXINS
in edx-platform in this repo (because edx-ora2 is imported into edx-platform), you need to manually add the methods/fields for the tests to work.
Here is an example of how I did it in my tests:
edx-ora2/openassessment/xblock/test/test_xml.py
Lines 219 to 251 in c76a89c
@ddt.file_data('data/serialize.json') | |
def test_serialize_with_tags(self, data): | |
self._configure_xblock(data) | |
# Create a mocked serialize tag data method that returns no data | |
def add_tags_to_node_no_tags(node): # pylint: disable=unused-argument | |
return | |
# Manually add the mocked method to the OpenAssessment block instance | |
# This method will be added in the edx-platform repo through applying XBLOCK_MIXINS | |
self.oa_block.add_tags_to_node = add_tags_to_node_no_tags | |
xml = serialize_content(self.oa_block) | |
# Confirm that no tags appear in the xml | |
self.assertNotIn("tags-v1", xml) | |
# Create a mocked serialize tag data method that returns data | |
def add_tags_to_node_with_tags(node): | |
# return "lightcast-skills:Typing,Microsoft Office" | |
node.set('tags-v1', 'lightcast-skills:Typing,Microsoft Office') | |
# Manually add the mocked method to the OpenAssessment block instance | |
# This method will be added in the edx-platform repo through applying XBLOCK_MIXINS | |
self.oa_block.add_tags_to_node = add_tags_to_node_with_tags | |
xml = serialize_content(self.oa_block) | |
# Confirm that tags appear in the xml | |
self.assertIn("tags-v1=\"lightcast-skills:Typing,Microsoft Office\"", xml) | |
# Clear the mocked serialize tag data method | |
del self.oa_block.add_tags_to_node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @yusuf-musleh! It took me some time but I figure it out with your help!
Could you take another look at it please?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2181 +/- ##
==========================================
+ Coverage 94.99% 95.01% +0.01%
==========================================
Files 191 191
Lines 20999 21014 +15
Branches 1898 1899 +1
==========================================
+ Hits 19949 19966 +17
+ Misses 786 785 -1
+ Partials 264 263 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
17f12dd
to
e8b7395
Compare
e17bca6
to
48f7a8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- I tested this by copy/pasting tagged ORA2 blocks using this code and feat: paste tags when pasting xblocks with tag data [FC-0049] edx-platform#34270 , and it works as expected.
- I read through the code
-
I checked for accessibility issuesN/A - Includes documentation
-
User-facing strings are extracted for translationN/A
@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
FYI @rpenido We can revert this change if open-craft/edx-platform#640 tests out ok. |
This reverts commit 5329fea.
Description
This PR adds support to deserialize tag info from the block XML, adding it to the new
xml_attributes
property. This is used to allow pasting OpenAsssessments components with their applied tags.More Information
Testing instructions