WebHost: Fix /api/generate (#2693)

This commit is contained in:
Remy Jette
2024-01-11 14:44:12 -08:00
committed by GitHub
parent b6f3ccb8c5
commit f530895c33
2 changed files with 21 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
import io
import unittest
import json
import yaml
class TestDocs(unittest.TestCase):
@@ -23,7 +25,7 @@ class TestDocs(unittest.TestCase):
response = self.client.post("/api/generate")
self.assertIn("No options found. Expected file attachment or json weights.", response.text)
def test_generation_queued(self):
def test_generation_queued_weights(self):
options = {
"Tester1":
{
@@ -40,3 +42,19 @@ class TestDocs(unittest.TestCase):
json_data = response.get_json()
self.assertTrue(json_data["text"].startswith("Generation of seed "))
self.assertTrue(json_data["text"].endswith(" started successfully."))
def test_generation_queued_file(self):
options = {
"game": "Archipelago",
"name": "Tester",
"Archipelago": {}
}
response = self.client.post(
"/api/generate",
data={
'file': (io.BytesIO(yaml.dump(options, encoding="utf-8")), "test.yaml")
},
)
json_data = response.get_json()
self.assertTrue(json_data["text"].startswith("Generation of seed "))
self.assertTrue(json_data["text"].endswith(" started successfully."))