|
1 | 1 | """Test for Word Cloud Block functional logic.""" |
2 | 2 | import json |
3 | | -import os |
4 | 3 | from unittest.mock import Mock |
5 | 4 |
|
6 | 5 | from django.conf import settings |
@@ -68,33 +67,13 @@ def test_xml_import_export_cycle(self): |
68 | 67 | assert block.num_inputs == 3 |
69 | 68 | assert block.num_top_words == 100 |
70 | 69 |
|
71 | | - if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK: |
72 | | - # For extracted XBlocks, we need to manually export the XML definition to a file to properly test the |
73 | | - # import/export cycle. This is because extracted XBlocks use XBlock core's `add_xml_to_node` method, |
74 | | - # which does not export the XML to a file like `XmlMixin.add_xml_to_node` does. |
75 | | - filepath = 'word_cloud/block_id.xml' |
76 | | - runtime.export_fs.makedirs(os.path.dirname(filepath), recreate=True) |
77 | | - with runtime.export_fs.open(filepath, 'wb') as fileObj: |
78 | | - runtime.export_to_xml(block, fileObj) |
79 | | - else: |
80 | | - node = etree.Element("unknown_root") |
81 | | - # This will export the olx to a separate file. |
82 | | - block.add_xml_to_node(node) |
| 70 | + node = etree.Element("unknown_root") |
| 71 | + # This will export the olx to a separate file. |
| 72 | + block.add_xml_to_node(node) |
83 | 73 |
|
84 | 74 | with runtime.export_fs.open('word_cloud/block_id.xml') as f: |
85 | 75 | exported_xml = f.read() |
86 | 76 |
|
87 | | - if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK: |
88 | | - # For extracted XBlocks, we need to remove the `xblock-family` attribute from the exported XML to ensure |
89 | | - # consistency with the original XML. |
90 | | - # This is because extracted XBlocks use the core XBlock's `add_xml_to_node` method, which includes this |
91 | | - # attribute, whereas `XmlMixin.add_xml_to_node` does not. |
92 | | - exported_xml_tree = etree.fromstring(exported_xml.encode('utf-8')) |
93 | | - etree.cleanup_namespaces(exported_xml_tree) |
94 | | - if 'xblock-family' in exported_xml_tree.attrib: |
95 | | - del exported_xml_tree.attrib['xblock-family'] |
96 | | - exported_xml = etree.tostring(exported_xml_tree, encoding='unicode', pretty_print=True) |
97 | | - |
98 | 77 | assert exported_xml == original_xml |
99 | 78 |
|
100 | 79 | def test_bad_ajax_request(self): |
|
0 commit comments