Apply treefmt
This commit is contained in:
parent
b2395ce611
commit
b2c240e87f
86 changed files with 374 additions and 456 deletions
|
@ -12,9 +12,11 @@ def test(subtest, webserver):
|
|||
# Helpers
|
||||
def curl_variable_test(node, variable, expected, url):
|
||||
value = node.succeed(
|
||||
f"curl -s --no-location -o /dev/null -w '%{{{variable}}}' '{url}'")
|
||||
assert value == expected, \
|
||||
f"curl -s --no-location -o /dev/null -w '%{{{variable}}}' '{url}'"
|
||||
)
|
||||
assert value == expected, (
|
||||
f"expected {variable} to be '{expected}' but got '{value}'"
|
||||
)
|
||||
|
||||
def expect_http_code(node, code, url):
|
||||
curl_variable_test(node, "http_code", code, url)
|
||||
|
@ -24,23 +26,21 @@ def test(subtest, webserver):
|
|||
|
||||
def expect_http_content(node, expectedContent, url):
|
||||
content = node.succeed(f"curl --no-location --silent '{url}'")
|
||||
assert content.strip() == expectedContent.strip(), f'''
|
||||
assert content.strip() == expectedContent.strip(), f"""
|
||||
expected content:
|
||||
{expectedContent}
|
||||
at {url} but got following content:
|
||||
{content}
|
||||
'''
|
||||
"""
|
||||
|
||||
# Tests
|
||||
with subtest("website is successfully served on localhost"):
|
||||
expect_http_code(webserver, "200", "http://localhost/index.html")
|
||||
expect_http_content(webserver, indexContent,
|
||||
"http://localhost/index.html")
|
||||
expect_http_content(webserver, indexContent, "http://localhost/index.html")
|
||||
|
||||
with subtest("example.com is in hosts file and a redirect to localhost"):
|
||||
webserver.succeed("grep example.com /etc/hosts")
|
||||
|
||||
url = "http://example.com/index.html"
|
||||
expect_http_code(webserver, "301", url)
|
||||
expect_http_location(
|
||||
webserver, "http://localhost/index.html", url)
|
||||
expect_http_location(webserver, "http://localhost/index.html", url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue