fixed the tests

This commit is contained in:
diginc 2018-01-03 21:35:53 -06:00
parent e5a56222a3
commit b33ea3b77f
2 changed files with 13 additions and 18 deletions

View File

@ -9,9 +9,6 @@ env:
- OS=debian ARCH=amd64
- OS=debian ARCH=armhf
- OS=debian ARCH=aarch64
- OS=alpine ARCH=amd64
- OS=alpine ARCH=armhf
# - OS=alpine ARCH=aarch64 # Impossible combo :(
python:
- "2.7"
install:

View File

@ -48,18 +48,22 @@ def test_indecies_are_present(RunningPiHole):
File('/var/www/html/pihole/index.html').exists
File('/var/www/html/pihole/index.js').exists
def validate_curl(http_rc, expected_http_code, page_contents):
if int(http_rc.rc) != 0 or int(http_rc.stdout) != expected_http_code:
print 'CURL return code: {}'.format(http_rc.rc)
print 'CURL stdout: {}'.format(http_rc.stdout)
print 'CURL stderr:{}'.format(http_rc.stderr)
print 'CURL file:\n{}\n'.format(page_contents.encode('ascii'))
@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ])
@pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] )
def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
expected_http_code = 200
validate_curl(http_rc, expected_http_code, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == expected_http_code
assert 'testblock.pi-hole.local' in page_contents
@ -70,12 +74,9 @@ def test_javascript_requests_load_as_expected(RunningPiHole, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
expected_http_code = 200
validate_curl(http_rc, expected_http_code, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == expected_http_code
assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in page_contents
@ -87,12 +88,9 @@ def test_admin_requests_load_as_expected(RunningPiHole, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
expected_http_code = 200
validate_curl(http_rc, expected_http_code, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == expected_http_code
for html_text in ['dns_queries_today', 'Content-Security-Policy', 'scripts/pi-hole/js/footer.js']: