@@ -67,7 +67,7 @@ def test_delete_paths(
6767 remainder : list [Path ],
6868) -> None :
6969 monkeypatch .chdir (text_dandiset .dspath )
70- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
70+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
7171 instance = text_dandiset .api .instance_id
7272 dandiset_id = text_dandiset .dandiset_id
7373 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -92,7 +92,7 @@ def test_delete_path_confirm(
9292 text_dandiset : SampleDandiset ,
9393) -> None :
9494 monkeypatch .chdir (text_dandiset .dspath )
95- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
95+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
9696 instance = text_dandiset .api .instance_id
9797 dandiset_id = text_dandiset .dandiset_id
9898 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -113,7 +113,7 @@ def test_delete_path_pyout(
113113 text_dandiset : SampleDandiset ,
114114) -> None :
115115 monkeypatch .chdir (text_dandiset .dspath )
116- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
116+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
117117 instance = text_dandiset .api .instance_id
118118 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
119119 delete (["subdir2/coconut.txt" ], dandi_instance = instance , force = True )
@@ -143,7 +143,7 @@ def test_delete_dandiset(
143143 paths : list [str ],
144144) -> None :
145145 monkeypatch .chdir (text_dandiset .dspath )
146- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
146+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
147147 instance = text_dandiset .api .instance_id
148148 dandiset_id = text_dandiset .dandiset_id
149149 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -166,7 +166,7 @@ def test_delete_dandiset_confirm(
166166 text_dandiset : SampleDandiset ,
167167) -> None :
168168 monkeypatch .chdir (text_dandiset .dspath )
169- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
169+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
170170 instance = text_dandiset .api .instance_id
171171 dandiset_id = text_dandiset .dandiset_id
172172 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -187,7 +187,7 @@ def test_delete_dandiset_mismatch(
187187 text_dandiset : SampleDandiset ,
188188) -> None :
189189 monkeypatch .chdir (text_dandiset .dspath )
190- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
190+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
191191 instance = text_dandiset .api .instance_id
192192 dandiset_id = text_dandiset .dandiset_id
193193 not_dandiset = str (int (dandiset_id ) - 1 ).zfill (6 )
@@ -216,7 +216,7 @@ def test_delete_instance_mismatch(
216216 text_dandiset : SampleDandiset ,
217217) -> None :
218218 monkeypatch .chdir (text_dandiset .dspath )
219- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
219+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
220220 instance = text_dandiset .api .instance_id
221221 dandiset_id = text_dandiset .dandiset_id
222222 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -242,7 +242,7 @@ def test_delete_instance_mismatch(
242242def test_delete_nonexistent_dandiset (
243243 local_dandi_api : DandiAPI , mocker : MockerFixture , monkeypatch : pytest .MonkeyPatch
244244) -> None :
245- monkeypatch . setenv ( "DANDI_API_KEY" , local_dandi_api .api_key )
245+ local_dandi_api .monkeypatch_set_api_key_env ( monkeypatch )
246246 instance = local_dandi_api .instance_id
247247 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
248248 with pytest .raises (NotFoundError ) as excinfo :
@@ -259,7 +259,7 @@ def test_delete_nonexistent_dandiset(
259259def test_delete_nonexistent_dandiset_skip_missing (
260260 local_dandi_api : DandiAPI , mocker : MockerFixture , monkeypatch : pytest .MonkeyPatch
261261) -> None :
262- monkeypatch . setenv ( "DANDI_API_KEY" , local_dandi_api .api_key )
262+ local_dandi_api .monkeypatch_set_api_key_env ( monkeypatch )
263263 instance = local_dandi_api .instance_id
264264 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
265265 delete (
@@ -277,7 +277,7 @@ def test_delete_nonexistent_asset(
277277 monkeypatch : pytest .MonkeyPatch ,
278278 text_dandiset : SampleDandiset ,
279279) -> None :
280- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
280+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
281281 instance = text_dandiset .api .instance_id
282282 dandiset_id = text_dandiset .dandiset_id
283283 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -304,7 +304,7 @@ def test_delete_nonexistent_asset_skip_missing(
304304 text_dandiset : SampleDandiset ,
305305 tmp_path : Path ,
306306) -> None :
307- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
307+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
308308 instance = text_dandiset .api .instance_id
309309 dandiset_id = text_dandiset .dandiset_id
310310 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -333,7 +333,7 @@ def test_delete_nonexistent_asset_folder(
333333 monkeypatch : pytest .MonkeyPatch ,
334334 text_dandiset : SampleDandiset ,
335335) -> None :
336- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
336+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
337337 instance = text_dandiset .api .instance_id
338338 dandiset_id = text_dandiset .dandiset_id
339339 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -360,7 +360,7 @@ def test_delete_nonexistent_asset_folder_skip_missing(
360360 text_dandiset : SampleDandiset ,
361361 tmp_path : Path ,
362362) -> None :
363- monkeypatch . setenv ( "DANDI_API_KEY" , text_dandiset .api .api_key )
363+ text_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
364364 instance = text_dandiset .api .instance_id
365365 dandiset_id = text_dandiset .dandiset_id
366366 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
@@ -387,7 +387,7 @@ def test_delete_nonexistent_asset_folder_skip_missing(
387387def test_delete_version (
388388 local_dandi_api : DandiAPI , mocker : MockerFixture , monkeypatch : pytest .MonkeyPatch
389389) -> None :
390- monkeypatch . setenv ( "DANDI_API_KEY" , local_dandi_api .api_key )
390+ local_dandi_api .monkeypatch_set_api_key_env ( monkeypatch )
391391 instance = local_dandi_api .instance_id
392392 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
393393 with pytest .raises (NotImplementedError ) as excinfo :
@@ -430,7 +430,7 @@ def test_delete_zarr_path(
430430 tmp_path : Path ,
431431) -> None :
432432 monkeypatch .chdir (zarr_dandiset .dspath )
433- monkeypatch . setenv ( "DANDI_API_KEY" , zarr_dandiset .api .api_key )
433+ zarr_dandiset .api .monkeypatch_set_api_key_env ( monkeypatch )
434434 instance = zarr_dandiset .api .instance_id
435435 delete_spy = mocker .spy (RESTFullAPIClient , "delete" )
436436 delete (["sample.zarr" ], dandi_instance = instance , devel_debug = True , force = True )
0 commit comments