| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  | # -*- coding: utf-8; -*- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | from unittest import TestCase | 
					
						
							| 
									
										
										
										
											2024-12-05 18:58:10 -06:00
										 |  |  | from unittest.mock import MagicMock, patch | 
					
						
							| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | import typer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from wuttjamaican.conf import WuttaConfig | 
					
						
							|  |  |  | from wuttjamaican.cli import base as mod | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | here = os.path.dirname(__file__) | 
					
						
							| 
									
										
										
										
											2025-08-30 21:25:44 -05:00
										 |  |  | example_conf = os.path.join(here, "example.conf") | 
					
						
							| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TestMakeCliConfig(TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_basic(self): | 
					
						
							| 
									
										
										
										
											2025-08-30 21:25:44 -05:00
										 |  |  |         ctx = MagicMock(params={"config_paths": [example_conf]}) | 
					
						
							| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  |         config = mod.make_cli_config(ctx) | 
					
						
							|  |  |  |         self.assertIsInstance(config, WuttaConfig) | 
					
						
							|  |  |  |         self.assertEqual(config.files_read, [example_conf]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TestTyperCallback(TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_basic(self): | 
					
						
							| 
									
										
										
										
											2025-08-30 21:25:44 -05:00
										 |  |  |         ctx = MagicMock(params={"config_paths": [example_conf]}) | 
					
						
							| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  |         mod.typer_callback(ctx) | 
					
						
							|  |  |  |         self.assertIsInstance(ctx.wutta_config, WuttaConfig) | 
					
						
							|  |  |  |         self.assertEqual(ctx.wutta_config.files_read, [example_conf]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-05 18:58:10 -06:00
										 |  |  | class TestTyperEagerImports(TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_basic(self): | 
					
						
							| 
									
										
										
										
											2025-08-30 21:25:44 -05:00
										 |  |  |         typr = mod.make_typer(name="foobreezy") | 
					
						
							|  |  |  |         with patch.object(mod, "load_entry_points") as load_entry_points: | 
					
						
							| 
									
										
										
										
											2024-12-05 18:58:10 -06:00
										 |  |  |             mod.typer_eager_imports(typr) | 
					
						
							| 
									
										
										
										
											2025-08-30 21:25:44 -05:00
										 |  |  |             load_entry_points.assert_called_once_with("foobreezy.typer_imports") | 
					
						
							| 
									
										
										
										
											2024-12-05 18:58:10 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-23 11:48:28 -06:00
										 |  |  | class TestMakeTyper(TestCase): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_basic(self): | 
					
						
							|  |  |  |         typr = mod.make_typer() | 
					
						
							|  |  |  |         self.assertIsInstance(typr, typer.Typer) |