Tests, WebHost: add tests for host_room and minor cleanup (#3619)

* Tests, WebHost: move out setUp and fix typing in api_generate

Also fixes a typo
and changes client to be per-test rather than a ClassVar

* Tests, WebHost: add tests for display_log endpoint

* Tests, WebHost: add tests for host_room endpoint

* Tests, WebHost: enable Flask DEBUG mode for tests

This provides the actual error if a test raised an exception on the server.

* Tests, WebHost: use user_path for logs

This is what custom_server does now.

* Tests, WebHost: avoid triggering security scans
This commit is contained in:
black-sliver
2024-07-07 16:51:10 +02:00
committed by GitHub
parent 9b22458f44
commit c96c554dfa
3 changed files with 233 additions and 20 deletions

View File

@@ -1,31 +1,16 @@
import io
import unittest
import json
import yaml
from . import TestBase
class TestDocs(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
from WebHostLib import app as raw_app
from WebHost import get_app
raw_app.config["PONY"] = {
"provider": "sqlite",
"filename": ":memory:",
"create_db": True,
}
raw_app.config.update({
"TESTING": True,
})
app = get_app()
cls.client = app.test_client()
def test_correct_error_empty_request(self):
class TestAPIGenerate(TestBase):
def test_correct_error_empty_request(self) -> None:
response = self.client.post("/api/generate")
self.assertIn("No options found. Expected file attachment or json weights.", response.text)
def test_generation_queued_weights(self):
def test_generation_queued_weights(self) -> None:
options = {
"Tester1":
{
@@ -43,7 +28,7 @@ class TestDocs(unittest.TestCase):
self.assertTrue(json_data["text"].startswith("Generation of seed "))
self.assertTrue(json_data["text"].endswith(" started successfully."))
def test_generation_queued_file(self):
def test_generation_queued_file(self) -> None:
options = {
"game": "Archipelago",
"name": "Tester",