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_html_to_nodes_multi_line(self):
self.assertEqual(
html_to_nodes(HTML_MULTI_LINES),
HTML_MULTI_LINES_NODES_LIST
)
self.assertEqual(
html_to_nodes(HTML_MULTI_LINES1),
HTML_MULTI_LINES_NODES_LIST
)
def test_html_to_nodes_invalid_html(self):
with self.assertRaises(InvalidHTML):
html_to_nodes('<p><b></b></p>')
def test_html_to_nodes_not_allowed_tag(self):
with self.assertRaises(NotAllowedTag):
html_to_nodes('')
def test_html_to_nodes(self):
self.assertEqual(
html_to_nodes(HTML_TEST_STR),
NODES_TEST_LIST
)
def test_html_to_nodes_multi_line(self):
self.assertEqual(
html_to_nodes(HTML_MULTI_LINES),
HTML_MULTI_LINES_NODES_LIST
)
self.assertEqual(
html_to_nodes(HTML_MULTI_LINES1),
HTML_MULTI_LINES_NODES_LIST
)
def test_no_starttag_node(self):
with self.assertRaises(InvalidHTML):
html_to_nodes(HTML_NO_STARTTAG)
def test_get_page(self):
telegraph = Telegraph()
response = telegraph.get_page('Hey-01-17-2', return_html=False)
self.assertEqual(
response['content'],
[{'tag': 'p', 'children': ['Hello, world!']}]
)
def test_get_page_html(self):
telegraph = Telegraph()
response = telegraph.get_page('Hey-01-17-2')
self.assertEqual(response['content'], '<p>Hello, world!</p>')
def test_get_page_without_content(self):
telegraph = Telegraph()
response = telegraph.get_page('Hey-01-17-2', return_content=False)
self.assertTrue('content' not in response)
def test_flow(self):
telegraph = Telegraph()
response = telegraph.create_account(
short_name='python telegraph',
author_name='Python Telegraph API wrapper',
author_url='https://github.com/python273/telegraph'
)
self.assertTrue('access_token' in response)
self.assertTrue('auth_url' in response)
response = telegraph.get_account_info()
self.assertEqual(response['short_name'], 'python telegraph')
response = telegraph.edit_account_info(
short_name='Python Telegraph Wrapper'
)
self.assertEqual(response['short_name'], 'Python Telegraph Wrapper')