mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-21 18:17:07 +00:00
Run web API test suite in GitHub Actions (#1009)
- Fixed ignore patterns in .dockerignore - Added healthchecks to backend and web containers - Reduced Docker image sizes - Removed RaSCSI references in various areas (e.g. rascsi -> backend) - Added compilation-only step to easyinstall.sh - Moved apt package lists to variables - Revert to triggering GitHub Actions runs on push - Updated web/frontend_checks workflow to run black and flake8 against all Python sources - Capture log files from backend/web containers - Fix None to float conversion bug when user agent is absent or unrecognised
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
import uuid
|
||||
import warnings
|
||||
import datetime
|
||||
|
||||
SCSI_ID = 6
|
||||
FILE_SIZE_1_MIB = 1048576
|
||||
@@ -13,7 +14,7 @@ def create_test_image(request, http_client):
|
||||
images = []
|
||||
|
||||
def create(image_type="hds", size=1, auto_delete=True):
|
||||
file_prefix = str(uuid.uuid4())
|
||||
file_prefix = f"{request.function.__name__}___{uuid.uuid4()}"
|
||||
file_name = f"{file_prefix}.{image_type}"
|
||||
|
||||
response = http_client.post(
|
||||
@@ -29,13 +30,19 @@ def create_test_image(request, http_client):
|
||||
raise Exception("Failed to create temporary image")
|
||||
|
||||
if auto_delete:
|
||||
images.append(file_name)
|
||||
images.append(
|
||||
{
|
||||
"file_name": file_name,
|
||||
"function": request.function,
|
||||
"created": str(datetime.datetime.now()),
|
||||
}
|
||||
)
|
||||
|
||||
return file_name
|
||||
|
||||
def delete():
|
||||
for image in images:
|
||||
response = http_client.post("/files/delete", data={"file_name": image})
|
||||
response = http_client.post("/files/delete", data={"file_name": image["file_name"]})
|
||||
if response.status_code != 200 or response.json()["status"] != STATUS_SUCCESS:
|
||||
warnings.warn(
|
||||
f"Failed to auto-delete file created with create_test_image fixture: {image}"
|
||||
|
||||
@@ -112,3 +112,9 @@ def test_show_manpage(http_client):
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "rascsi" in response_data["data"]["manpage"]
|
||||
|
||||
|
||||
# route("/healthcheck", methods=["GET"])
|
||||
def test_healthcheck(http_client):
|
||||
response = http_client.get("/healthcheck")
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
default_base_url = "http://rascsi_web" if os.getenv("DOCKER") else "http://localhost:8080"
|
||||
default_base_url = "http://web" if os.getenv("DOCKER") else "http://localhost:8080"
|
||||
|
||||
parser.addoption("--home_dir", action="store", default="/home/pi")
|
||||
parser.addoption("--base_url", action="store", default=default_base_url)
|
||||
|
||||
Reference in New Issue
Block a user