Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nodes_to_html(self):
self.assertEqual(
nodes_to_html(NODES_TEST_LIST),
HTML_TEST_STR
)
def test_nodes_to_html_nested(self):
self.assertEqual(
nodes_to_html([
{'tag': 'a', 'children': [
{'tag': 'b', 'children': [
{'tag': 'c', 'children': [
{'tag': 'd', 'children': []}
]}
]}
]}
]),
'<a><b></b></a>'
)
def test_nodes_to_html_blank(self):
self.assertEqual(
nodes_to_html([]),
''
)
def get_page(self, path, return_content=True, return_html=True):
""" Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returned
:param return_html: If true, returns HTML instead of Nodes list
"""
response = self._telegraph.method('getPage', path=path, values={
'return_content': return_content
})
if return_content and return_html:
response['content'] = nodes_to_html(response['content'])
return response