| 
									
										
										
										
											2022-05-03 22:14:03 +02:00
										 |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  | import Utils | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-02 21:12:58 +02:00
										 |  |  | from werkzeug.utils import secure_filename | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  | import WebHost | 
					
						
							| 
									
										
										
										
											2022-05-03 22:14:03 +02:00
										 |  |  | from worlds.AutoWorld import AutoWorldRegister | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  | class TestDocs(unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2022-12-08 02:06:34 +01:00
										 |  |  |     @classmethod | 
					
						
							|  |  |  |     def setUpClass(cls) -> None: | 
					
						
							| 
									
										
										
										
											2025-08-02 21:12:58 +02:00
										 |  |  |         WebHost.copy_tutorials_files_to_static() | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |     def test_has_tutorial(self): | 
					
						
							| 
									
										
										
										
											2022-05-03 22:14:03 +02:00
										 |  |  |         for game_name, world_type in AutoWorldRegister.world_types.items(): | 
					
						
							|  |  |  |             if not world_type.hidden: | 
					
						
							|  |  |  |                 with self.subTest(game_name): | 
					
						
							| 
									
										
										
										
											2025-08-02 21:12:58 +02:00
										 |  |  |                     tutorials = world_type.web.tutorials | 
					
						
							|  |  |  |                     self.assertGreater(len(tutorials), 0, msg=f"{game_name} has no setup tutorial.") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     safe_name = secure_filename(game_name) | 
					
						
							|  |  |  |                     target_path = Utils.local_path("WebHostLib", "static", "generated", "docs", safe_name) | 
					
						
							|  |  |  |                     for tutorial in tutorials: | 
					
						
							|  |  |  |                         self.assertTrue( | 
					
						
							|  |  |  |                             os.path.isfile(Utils.local_path(target_path, secure_filename(tutorial.file_name))), | 
					
						
							|  |  |  |                             f'{game_name} missing tutorial file {tutorial.file_name}.' | 
					
						
							|  |  |  |                         ) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-22 06:00:27 -05:00
										 |  |  |     def test_has_game_info(self): | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  |         for game_name, world_type in AutoWorldRegister.world_types.items(): | 
					
						
							|  |  |  |             if not world_type.hidden: | 
					
						
							| 
									
										
										
										
											2025-08-02 21:12:58 +02:00
										 |  |  |                 safe_name = secure_filename(game_name) | 
					
						
							| 
									
										
										
										
											2024-11-15 17:31:03 +01:00
										 |  |  |                 target_path = Utils.local_path("WebHostLib", "static", "generated", "docs", safe_name) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  |                 for game_info_lang in world_type.web.game_info_languages: | 
					
						
							|  |  |  |                     with self.subTest(game_name): | 
					
						
							| 
									
										
										
										
											2024-11-15 17:31:03 +01:00
										 |  |  |                         self.assertTrue( | 
					
						
							|  |  |  |                             os.path.isfile(Utils.local_path(target_path, f'{game_info_lang}_{safe_name}.md')), | 
					
						
							| 
									
										
										
										
											2022-05-18 17:08:29 -05:00
										 |  |  |                             f'{game_name} missing game info file for "{game_info_lang}" language.' | 
					
						
							|  |  |  |                         ) |