WebHost: restore old silent ignore of mimetypes in json getting (#1292)

* WebHost: restore old silent ignore of mimetypes in json getting of /api/generate

* Tests: add tests for /api/generate
This commit is contained in:
Fabian Dill
2022-12-05 22:27:15 +01:00
committed by GitHub
parent 4412434976
commit 32b8f9f9f3
2 changed files with 44 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
import unittest
import json
class TestDocs(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
from WebHost import get_app, raw_app
raw_app.config["PONY"] = {
"provider": "sqlite",
"filename": ":memory:",
"create_db": True,
}
app = get_app()
app.config.update({
"TESTING": True,
})
cls.client = app.test_client()
def testCorrectErrorEmptyRequest(self):
response = self.client.post("/api/generate")
self.assertIn("No options found. Expected file attachment or json weights.", response.text)
def testGenerationQueued(self):
options = {
"Tester1":
{
"game": "Archipelago",
"name": "Tester",
"Archipelago": {}
}
}
response = self.client.post(
"/api/generate",
data=json.dumps({"weights": options}),
content_type='application/json'
)
json_data = response.get_json()
self.assertTrue(json_data["text"].startswith("Generation of seed "))
self.assertTrue(json_data["text"].endswith(" started successfully."))