bare render tests

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-02-28 08:39:58 -05:00
parent e9c162f5f7
commit 565cd496c2
+41 -2
View File
@@ -44,8 +44,8 @@ def test_links():
r = get()
about = r.html.find('#about', first=True)
len(about.links) == 6
len(about.absolute_links) == 6
assert len(about.links) == 6
assert len(about.absolute_links) == 6
def test_search():
@@ -79,5 +79,44 @@ def test_anchor_links():
assert '#site-map' in r.html.links
def test_render():
r = get()
script = """
() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio,
}
}
"""
val = r.html.render(script=script)
for value in ('width', 'height', 'deviceScaleFactor'):
assert value in val
about = r.html.find('#about', first=True)
assert len(about.links) == 6
def test_bare_render():
doc = """<a href='https://httpbin.org'>"""
html = HTML(html=doc)
script = """
() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio,
}
}
"""
val = html.render(script=script, reload=False)
for value in ('width', 'height', 'deviceScaleFactor'):
assert value in val
assert html.find('html')
assert 'https://httpbin.org' in html.links
if __name__ == '__main__':
test_xpath()