@@ -60,6 +60,25 @@ def test_default_init_get_file_and_import_path(self):
6060 self .assertTrue ('tests/mocks/apigateway/resolver/directory_handlers/home/__init__.py' in file_path )
6161 self .assertEqual ('tests.mocks.apigateway.resolver.directory_handlers.home.__init__' , import_path )
6262
63+ def test_base_path_get_file_and_import_path (self ):
64+ base_path_request = mock_request .get_basic ()
65+ base_path_request ['path' ] = self .base_path
66+ request = Request (base_path_request )
67+ file_path , import_path = self .directory_resolver ._get_file_and_import_path (request .path )
68+ self .assertTrue ('tests/mocks/apigateway/resolver/directory_handlers/__init__.py' in file_path )
69+ self .assertEqual ('tests.mocks.apigateway.resolver.directory_handlers.__init__' , import_path )
70+
71+ def test_base_path_raises_without_init_file (self ):
72+ handler_path = 'tests/mocks/apigateway/resolver/directory_handlers_no_root_init'
73+ base_path_request = mock_request .get_basic ()
74+ base_path_request ['path' ] = self .base_path
75+ request = Request (base_path_request )
76+ directory_resolver = DirectoryModeResolver (base_path = self .base_path , handlers = handler_path )
77+ with self .assertRaises (ApiException ) as resolver_error :
78+ directory_resolver ._get_file_and_import_path (request .path )
79+ self .assertEqual (resolver_error .exception .code , 404 )
80+ self .assertEqual (resolver_error .exception .message , 'route not found' )
81+
6382 def test_dynamic_get_file_and_import_path (self ):
6483 request = Request (self .dynamic_request )
6584 file_path , import_path = self .directory_resolver ._get_file_and_import_path (request .path )
@@ -102,4 +121,3 @@ def test_triple_nested_dynamic_get_file_and_import_path(self):
102121 file_path , import_path = self .directory_resolver ._get_file_and_import_path (request .path )
103122 self .assertTrue ('tests/mocks/apigateway/resolver/directory_handlers/user/_user_id/item/_item_id.py' in file_path )
104123 self .assertEqual ('tests.mocks.apigateway.resolver.directory_handlers.user._user_id.item._item_id' , import_path )
105-
0 commit comments