-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #584 from Synss/issue-581
adds (very) basic integration test
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
harp/commandline/cookiecutters/project/{{cookiecutter.__dir_name}}/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
26 changes: 26 additions & 0 deletions
26
harp/commandline/cookiecutters/project/{{cookiecutter.__dir_name}}/tests/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
6 changes: 6 additions & 0 deletions
6
harp/commandline/cookiecutters/project/{{cookiecutter.__dir_name}}/tests/test_e2e.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|