Skip to content

Commit

Permalink
bare render tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
  • Loading branch information
kennethreitz committed Feb 28, 2018
1 parent e9c162f commit 565cd49
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions tests/test_requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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()

0 comments on commit 565cd49

Please sign in to comment.