mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
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:
@@ -0,0 +1,36 @@
|
||||
import unittest
|
||||
import typing
|
||||
from uuid import uuid4
|
||||
|
||||
from flask import Flask
|
||||
from flask.testing import FlaskClient
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
app: typing.ClassVar[Flask]
|
||||
client: FlaskClient
|
||||
|
||||
@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,
|
||||
"DEBUG": True,
|
||||
})
|
||||
try:
|
||||
cls.app = get_app()
|
||||
except AssertionError as e:
|
||||
# since we only have 1 global app object, this might fail, but luckily all tests use the same config
|
||||
if "register_blueprint" not in e.args[0]:
|
||||
raise
|
||||
cls.app = raw_app
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.client = self.app.test_client()
|
||||
|
||||
Reference in New Issue
Block a user