@@ -145,6 +145,45 @@ def test_wd_lexeme_dump_download_wrapper_latest(
145145 for call in mock_get .call_args_list :
146146 self .assertEqual (call .kwargs .get ("headers" ), WMF_HEADERS )
147147
148+ @patch ("scribe_data.cli.download.wikidata_lexeme_dump.requests.get" )
149+ @patch (
150+ "scribe_data.cli.download.wikidata_lexeme_dump.check_lexeme_dump_prompt_download" ,
151+ return_value = False ,
152+ )
153+ @patch ("scribe_data.cli.download.wikidata_lexeme_dump.open" , new_callable = mock_open )
154+ @patch ("scribe_data.cli.download.wikidata_lexeme_dump.tqdm" )
155+ @patch ("scribe_data.cli.download.wikidata_lexeme_dump.os.makedirs" )
156+ @patch ("scribe_data.cli.download.wikidata_lexeme_dump.questionary.confirm" )
157+ def test_wd_lexeme_dump_download_wrapper_accepts_str_output_dir (
158+ self ,
159+ mock_confirm : MagicMock ,
160+ mock_makedirs : MagicMock ,
161+ mock_tqdm : MagicMock ,
162+ mock_file : MagicMock ,
163+ mock_check_prompt : MagicMock ,
164+ mock_get : MagicMock ,
165+ ) -> None :
166+ """
167+ CLI passes -wdp as str; Path join must not raise TypeError.
168+ """
169+ mock_confirm .return_value .ask .return_value = True
170+ mock_get .return_value .text = 'href="latest-all.json.bz2"'
171+ mock_get .return_value .raise_for_status = MagicMock ()
172+ mock_get .return_value .headers = {"content-length" : "100" }
173+ mock_get .return_value .iter_content = lambda chunk_size : [b"data" ] * 10
174+
175+ download_path = wd_lexeme_dump_download_wrapper (
176+ output_dir = "./scribe_data_wikidata_dumps_export"
177+ )
178+ self .assertIsNotNone (download_path )
179+ self .assertEqual (
180+ download_path ,
181+ Path ("scribe_data_wikidata_dumps_export" ) / "latest-lexemes.json.bz2" ,
182+ )
183+ mock_makedirs .assert_called_with (
184+ Path ("scribe_data_wikidata_dumps_export" ), exist_ok = True
185+ )
186+
148187 @patch ("scribe_data.utils.questionary.select" )
149188 @patch (
150189 "scribe_data.utils.Path.glob" ,
0 commit comments