mirror of
				https://github.com/MarioSpore/Grinch-AP.git
				synced 2025-10-21 20:21:32 -06:00 
			
		
		
		
	 c96c554dfa
			
		
	
	c96c554dfa
	
	
	
		
			
			* 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
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import io
 | |
| import json
 | |
| import yaml
 | |
| 
 | |
| from . import TestBase
 | |
| 
 | |
| 
 | |
| 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) -> None:
 | |
|         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."))
 | |
| 
 | |
|     def test_generation_queued_file(self) -> None:
 | |
|         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."))
 |