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_import_html_and_add_parent():
from buku import import_html
from bs4 import BeautifulSoup
html_text = """<dt><h3>1s</h3>
<dl><p>
</p><dt><a href="http://example.com/"></a>"""
exp_res = ('http://example.com/', None, ',1s,', None, 0, True, False)
html_soup = BeautifulSoup(html_text, 'html.parser')
res = list(import_html(html_soup, True, None))
assert res[0] == exp_res
</dt></dl></dt>
def test_import_html_and_new_tag():
from buku import import_html
from bs4 import BeautifulSoup
html_text = """<dt><a href="https://github.com/j">GitHub</a>
</dt><dd>comment for the bookmark here"""
exp_res = (
'https://github.com/j', 'GitHub', ',tag1,tag2,tag3,',
'comment for the bookmark here', 0, True, False
)
html_soup = BeautifulSoup(html_text, 'html.parser')
res = list(import_html(html_soup, False, 'tag3'))
assert res[0] == exp_res
</dd>
"""DT><a href="https://github.com/j">GitHub</a>
<dd>comment for the bookmark here""",
((
'https://github.com/j', 'GitHub', ',tag1,tag2,',
'comment for the bookmark here', 0, True, False
),)
)
]
)
def test_import_html(html_text, exp_res):
"""test method."""
from buku import import_html
from bs4 import BeautifulSoup
html_soup = BeautifulSoup(html_text, 'html.parser')
res = list(import_html(html_soup, False, None))
for item, exp_item in zip(res, exp_res):
assert item == exp_item, 'Actual item:\n{}'.format(item)
</dd>