xoxys.homeassistant_docker/molecule/centos7/tests/test_default.py
Robert Kaussow c8edca4d5e
Some checks failed
continuous-integration/drone/push Build is failing
refactor: rewrite role for docker deployment
2021-03-14 17:46:46 +01:00

35 lines
939 B
Python

import os
import time
import testinfra.utils.ansible_runner
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_homeassistant_running(host):
homeassistant = host.docker("homeassistant")
assert homeassistant.is_running
def test_homeassistant_socket(host):
# Verify the socket is listening for HTTP traffic
for _ in range(30):
if host.socket("tcp://127.0.0.1:8123").is_listening:
break
time.sleep(1)
assert host.socket("tcp://127.0.0.1:8123").is_listening
def test_homeassistant_conn_error(host):
code = int(host.run("curl -sL -w '%{http_code}' http://127.0.0.1:8123/ -o /dev/null").stdout)
body = host.run("curl -sLX GET http://127.0.0.1:8123/").stdout
assert code == 200
assert "Home Assistant" in body