@@ -103,10 +103,10 @@ def test_custom_conf_py_path_dir(self):
103103 ]
104104 self .assertEqual (expected , build_command )
105105
106- @patch ("os.path.expanduser " )
107- def test_container (self , mock_expanduser ):
106+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent " )
107+ def test_container (self , mock_get_toplevel_of_doc_builder_parent ):
108108 """Tests usage with container"""
109- mock_expanduser .return_value = "/path/to/username"
109+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
110110 conf_py_path = os .path .join (os .path .dirname (__file__ ), "conf.py" )
111111 build_command = get_build_command (
112112 build_dir = "/path/to/username/foorepos/foodocs/versions/main" ,
@@ -125,8 +125,8 @@ def test_container(self, mock_expanduser):
125125 "foo" ,
126126 "--user" ,
127127 self .uid_gid ,
128- "--mount " ,
129- "type=bind,source= /path/to/username,target= /home/user/mounted_home" ,
128+ "-v " ,
129+ "/path/to/username: /home/user/mounted_home:U " ,
130130 "--workdir" ,
131131 "/home/user/mounted_home/foorepos/foocode/doc" ,
132132 "-t" ,
@@ -144,10 +144,10 @@ def test_container(self, mock_expanduser):
144144 print ("build_command: +" , " " .join (build_command ))
145145 self .assertEqual (expected , build_command )
146146
147- @patch ("os.path.expanduser " )
148- def test_container_relpath (self , mock_expanduser ):
147+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent " )
148+ def test_container_relpath (self , mock_get_toplevel_of_doc_builder_parent ):
149149 """Tests usage with container, with a relative path to build_dir"""
150- mock_expanduser .return_value = "/path/to/username"
150+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
151151 build_command = get_build_command (
152152 build_dir = "../../foodocs/versions/main" ,
153153 run_from_dir = "/path/to/username/foorepos/foocode/doc" ,
@@ -164,8 +164,8 @@ def test_container_relpath(self, mock_expanduser):
164164 "foo" ,
165165 "--user" ,
166166 self .uid_gid ,
167- "--mount " ,
168- "type=bind,source= /path/to/username,target= /home/user/mounted_home" ,
167+ "-v " ,
168+ "/path/to/username: /home/user/mounted_home:U " ,
169169 "--workdir" ,
170170 "/home/user/mounted_home/foorepos/foocode/doc" ,
171171 "-t" ,
@@ -182,10 +182,10 @@ def test_container_relpath(self, mock_expanduser):
182182 ]
183183 self .assertEqual (expected , build_command )
184184
185- @patch ("os.path.expanduser " )
186- def test_container_no_clitool_given (self , mock_expanduser ):
185+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent " )
186+ def test_container_no_clitool_given (self , mock_get_toplevel_of_doc_builder_parent ):
187187 """Tests usage with container"""
188- mock_expanduser .return_value = "/path/to/username"
188+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
189189 conf_py_path = os .path .join (os .path .dirname (__file__ ), "conf.py" )
190190 build_command = get_build_command (
191191 build_dir = "/path/to/username/foorepos/foodocs/versions/main" ,
@@ -203,8 +203,8 @@ def test_container_no_clitool_given(self, mock_expanduser):
203203 "foo" ,
204204 "--user" ,
205205 self .uid_gid ,
206- "--mount " ,
207- "type=bind,source= /path/to/username,target= /home/user/mounted_home" ,
206+ "-v " ,
207+ "/path/to/username: /home/user/mounted_home:U " ,
208208 "--workdir" ,
209209 "/home/user/mounted_home/foorepos/foocode/doc" ,
210210 "-t" ,
@@ -224,13 +224,11 @@ def test_container_no_clitool_given(self, mock_expanduser):
224224 build_command in [["podman" ] + expected , build_command == ["docker" ] + expected ]
225225 )
226226
227- @patch ("os.path.expanduser" )
228- def test_container_builddir_not_in_home (self , mock_expanduser ):
229- """If build_dir is not in the user's home directory, should raise an exception"""
230- mock_expanduser .return_value = "/path/to/username"
231- with self .assertRaisesRegex (
232- RuntimeError , "build directory must reside under your home directory"
233- ):
227+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent" )
228+ def test_container_builddir_not_in_db_checkout (self , mock_get_toplevel_of_doc_builder_parent ):
229+ """If build_dir is not in parent of doc-builder, should raise an exception"""
230+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
231+ with self .assertRaisesRegex (RuntimeError , "build directory must be somewhere in" ):
234232 _ = get_build_command (
235233 build_dir = "/path/to/other/foorepos/foodocs/versions/main" ,
236234 run_from_dir = "/path/to/username/foorepos/foocode/doc" ,
@@ -240,14 +238,11 @@ def test_container_builddir_not_in_home(self, mock_expanduser):
240238 version = "None" ,
241239 )
242240
243- @patch ("os.path.expanduser" )
244- def test_container_runfromdir_not_in_home (self , mock_expanduser ):
245- """If run_from_dir is not in the user's home directory, should raise an exception"""
246- mock_expanduser .return_value = "/path/to/username"
247- with self .assertRaisesRegex (
248- RuntimeError ,
249- "build_docs must be run from somewhere in your home directory" ,
250- ):
241+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent" )
242+ def test_container_runfromdir_not_in_db_parent (self , mock_get_toplevel_of_doc_builder_parent ):
243+ """If run_from_dir is not in parent of doc-builder, should raise an exception"""
244+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
245+ with self .assertRaisesRegex (RuntimeError , "build_docs must be run from somewhere in" ):
251246 _ = get_build_command (
252247 build_dir = "/path/to/username/foorepos/foodocs/versions/main" ,
253248 run_from_dir = "/path/to/other/foorepos/foocode/doc" ,
@@ -257,10 +252,10 @@ def test_container_runfromdir_not_in_home(self, mock_expanduser):
257252 version = "None" ,
258253 )
259254
260- @patch ("os.path.expanduser " )
261- def test_container_runfromdir_relative (self , mock_expanduser ):
255+ @patch ("doc_builder.sys_utils.get_toplevel_of_doc_builder_parent " )
256+ def test_container_runfromdir_relative (self , mock_get_toplevel_of_doc_builder_parent ):
262257 """If run_from_dir is relative, should raise an exception"""
263- mock_expanduser .return_value = "/path/to/username"
258+ mock_get_toplevel_of_doc_builder_parent .return_value = "/path/to/username"
264259 with self .assertRaisesRegex (
265260 RuntimeError ,
266261 "Expect absolute path; got" ,
0 commit comments