Skip to content

Commit

Permalink
Merge pull request #584 from Synss/issue-581
Browse files Browse the repository at this point in the history
adds (very) basic integration test
  • Loading branch information
hartym authored Nov 1, 2024
2 parents b6eaced + 85737be commit 85904bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
POETRY ?= $(shell which poetry || echo poetry)

.PHONY: start install
.PHONY: start install test


start: install
$(POETRY) run harp server{% if cookiecutter.create_application %} --enable {{cookiecutter.__pkg_name}}{% endif %}{% if cookiecutter.create_config %} --file config.yml{% endif %}

install:
$(POETRY) install

test: install
$(RUN) pytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from subprocess import Popen, PIPE
from http.client import HTTPConnection
import time

@pytest.fixture(scope="session")
def process():
process = Popen( ["make", "start"], stdout=PIPE)
retries = 5
while retries > 0:
conn = HTTPConnection("localhost:4080")
try:
conn.request("HEAD", "/")
response = conn.getresponse()
if response is not None:
yield process
break
except ConnectionRefusedError:
time.sleep(1)
retries -= 1

if not retries:
raise RuntimeError("Failed to start http server")
else:
process.terminate()
process.wait()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import httpx

def test_get_dashboard(process):
response = httpx.get('http://localhost:4080/')
assert response.status_code == 200

0 comments on commit 85904bb

Please sign in to comment.