def test_get_rte_components(self) -> None: test_data = ( '<p>Test text ' '<oppia-noninteractive-math ' 'math_content-with-value="{&quot;raw_latex&quot;:&qu' 'ot;\\\\frac{x}{y}&quot;,&quot;svg_filename&quot;:' '&quot;&quot;}">' '</oppia-noninteractive-math></p><p> ' '<oppia-noninteractive-link ' 'text-with-value=' '"&quot;Link\\&quot;quoted text\\&quot;' '&#39;singlequotes&#39;&quot;" ' 'url-with-value="&quot;https://www.example.com&quot;">' '</oppia-noninteractive-link>.</p>' '<p>Video</p>' '<p><oppia-noninteractive-video autoplay-with-value="false" ' 'end-with-value="0" start-with-value="0" ' 'video_id-with-value="&quot;' 'https://www.youtube.com/watch?v=Ntcw0H0hwPU&quot;">' '</oppia-noninteractive-video><br></p>') expected_components: List[html_cleaner.ComponentsDict] = [{ 'customization_args': { 'text-with-value': u'Link"quoted text"\'singlequotes\'', 'url-with-value': u'https://www.example.com' }, 'id': 'oppia-noninteractive-link' }, { 'customization_args': { 'start-with-value': 0, 'end-with-value': 0, 'video_id-with-value': (u'https://www.youtube.com/watch?' u'v=Ntcw0H0hwPU'), 'autoplay-with-value': False }, 'id': 'oppia-noninteractive-video' }, { 'customization_args': { 'math_content-with-value': { u'raw_latex': u'\\frac{x}{y}', u'svg_filename': u'' } }, 'id': 'oppia-noninteractive-math' }] components: List[html_cleaner.ComponentsDict] = ( html_cleaner.get_rte_components(test_data)) self.assertEqual(len(components), len(expected_components)) for component in components: self.assertIn(component, expected_components)
def test_get_rte_components(self): test_data = ( '<p>Test text ' '<oppia-noninteractive-math ' 'raw_latex-with-value="&quot;\\frac{x}{y}&quot;">' '</oppia-noninteractive-math></p><p> ' '<oppia-noninteractive-link ' 'text-with-value="&quot;Link&quot;" ' 'url-with-value="&quot;https://www.example.com&quot;">' '</oppia-noninteractive-link>.</p>' '<p>Video</p>' '<p><oppia-noninteractive-video autoplay-with-value="false" ' 'end-with-value="0" start-with-value="0" ' 'video_id-with-value="&quot;' 'https://www.youtube.com/watch?v=Ntcw0H0hwPU&quot;">' '</oppia-noninteractive-video><br></p>' ) expected_components = [ { 'customization_args': { 'text-with-value': u'Link', 'url-with-value': u'https://www.example.com'}, 'id': 'oppia-noninteractive-link' }, { 'customization_args': { 'start-with-value': 0, 'end-with-value': 0, 'video_id-with-value': ( u'https://www.youtube.com/watch?' u'v=Ntcw0H0hwPU'), 'autoplay-with-value': False }, 'id': 'oppia-noninteractive-video' }, { 'customization_args': { 'raw_latex-with-value': u'\\frac{x}{y}' }, 'id': 'oppia-noninteractive-math' } ] components = html_cleaner.get_rte_components(test_data) self.assertEqual(len(components), len(expected_components)) for component in components: self.assertIn(component, expected_components)