@@ -69,21 +69,22 @@ def asjson(self):
69
69
class TestWithMocks :
70
70
vcf_path = "tests/data/vcf/sample.vcf.gz"
71
71
72
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
72
73
@mock .patch ("bio2zarr.vcf2zarr.explode" )
73
- def test_vcf_explode (self , mocked , tmp_path ):
74
+ def test_vcf_explode (self , mocked , tmp_path , progress , flag ):
74
75
icf_path = tmp_path / "icf"
75
76
runner = ct .CliRunner (mix_stderr = False )
76
77
result = runner .invoke (
77
78
cli .vcf2zarr_main ,
78
- f"explode { self .vcf_path } { icf_path } " ,
79
+ f"explode { self .vcf_path } { icf_path } { flag } " ,
79
80
catch_exceptions = False ,
80
81
)
81
82
assert result .exit_code == 0
82
83
assert len (result .stdout ) == 0
83
84
assert len (result .stderr ) == 0
84
- mocked . assert_called_once_with (
85
- str ( icf_path ), ( self . vcf_path ,), ** DEFAULT_EXPLODE_ARGS
86
- )
85
+ args = dict ( DEFAULT_EXPLODE_ARGS )
86
+ args [ "show_progress" ] = progress
87
+ mocked . assert_called_once_with ( str ( icf_path ), ( self . vcf_path ,), ** args )
87
88
88
89
@pytest .mark .parametrize ("compressor" , ["lz4" , "zstd" ])
89
90
@mock .patch ("bio2zarr.vcf2zarr.explode" )
@@ -286,23 +287,26 @@ def test_vcf_explode_missing_and_existing_vcf(self, mocked, tmp_path):
286
287
assert "'no_such_file' does not exist" in result .stderr
287
288
mocked .assert_not_called ()
288
289
290
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
289
291
@mock .patch ("bio2zarr.vcf2zarr.explode_init" , return_value = FakeWorkSummary (5 ))
290
- def test_vcf_dexplode_init (self , mocked , tmp_path ):
292
+ def test_vcf_dexplode_init (self , mocked , tmp_path , progress , flag ):
291
293
runner = ct .CliRunner (mix_stderr = False )
292
294
icf_path = tmp_path / "icf"
293
295
result = runner .invoke (
294
296
cli .vcf2zarr_main ,
295
- f"dexplode-init { self .vcf_path } { icf_path } 5" ,
297
+ f"dexplode-init { self .vcf_path } { icf_path } 5 { flag } " ,
296
298
catch_exceptions = False ,
297
299
)
298
300
assert result .exit_code == 0
299
301
assert len (result .stderr ) == 0
300
302
assert list (result .stdout .split ()) == ["num_partitions" , "5" ]
303
+ args = dict (DEFAULT_DEXPLODE_INIT_ARGS )
304
+ args ["show_progress" ] = progress
301
305
mocked .assert_called_once_with (
302
306
str (icf_path ),
303
307
(self .vcf_path ,),
304
308
target_num_partitions = 5 ,
305
- ** DEFAULT_DEXPLODE_INIT_ARGS ,
309
+ ** args ,
306
310
)
307
311
308
312
@pytest .mark .parametrize ("num_partitions" , ["-- -1" , "0" , "asdf" , "1.112" ])
@@ -421,43 +425,51 @@ def test_mkschema(self, mocked, tmp_path):
421
425
# mocked.assert_called_once_with("path", stdout)
422
426
mocked .assert_called_once ()
423
427
428
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
424
429
@mock .patch ("bio2zarr.vcf2zarr.encode" )
425
- def test_encode (self , mocked , tmp_path ):
430
+ def test_encode (self , mocked , tmp_path , progress , flag ):
426
431
icf_path = tmp_path / "icf"
427
432
icf_path .mkdir ()
428
433
zarr_path = tmp_path / "zarr"
429
434
runner = ct .CliRunner (mix_stderr = False )
430
435
result = runner .invoke (
431
- cli .vcf2zarr_main , f"encode { icf_path } { zarr_path } " , catch_exceptions = False
436
+ cli .vcf2zarr_main ,
437
+ f"encode { icf_path } { zarr_path } { flag } " ,
438
+ catch_exceptions = False ,
432
439
)
433
440
assert result .exit_code == 0
434
441
assert len (result .stdout ) == 0
435
442
assert len (result .stderr ) == 0
443
+ args = DEFAULT_ENCODE_ARGS
444
+ args ["show_progress" ] = progress
436
445
mocked .assert_called_once_with (
437
446
str (icf_path ),
438
447
str (zarr_path ),
439
- ** DEFAULT_ENCODE_ARGS ,
448
+ ** args ,
440
449
)
441
450
451
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
442
452
@mock .patch ("bio2zarr.vcf2zarr.encode_init" , return_value = FakeWorkSummary (10 ))
443
- def test_dencode_init (self , mocked , tmp_path ):
453
+ def test_dencode_init (self , mocked , tmp_path , progress , flag ):
444
454
icf_path = tmp_path / "icf"
445
455
icf_path .mkdir ()
446
456
zarr_path = tmp_path / "zarr"
447
457
runner = ct .CliRunner (mix_stderr = False )
448
458
result = runner .invoke (
449
459
cli .vcf2zarr_main ,
450
- f"dencode-init { icf_path } { zarr_path } 10" ,
460
+ f"dencode-init { icf_path } { zarr_path } 10 { flag } " ,
451
461
catch_exceptions = False ,
452
462
)
453
463
assert result .exit_code == 0
454
464
assert list (result .stdout .split ()) == ["num_partitions" , "10" ]
455
465
assert len (result .stderr ) == 0
466
+ args = DEFAULT_DENCODE_INIT_ARGS
467
+ args ["show_progress" ] = progress
456
468
mocked .assert_called_once_with (
457
469
str (icf_path ),
458
470
str (zarr_path ),
459
471
target_num_partitions = 10 ,
460
- ** DEFAULT_DENCODE_INIT_ARGS ,
472
+ ** args ,
461
473
)
462
474
463
475
@mock .patch ("bio2zarr.vcf2zarr.encode_partition" )
@@ -494,32 +506,40 @@ def test_vcf_dencode_partition_one_based(self, mocked, tmp_path):
494
506
str (zarr_path ), 0 , ** DEFAULT_DENCODE_PARTITION_ARGS
495
507
)
496
508
509
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
497
510
@mock .patch ("bio2zarr.vcf2zarr.encode_finalise" )
498
- def test_vcf_dencode_finalise (self , mocked , tmp_path ):
511
+ def test_vcf_dencode_finalise (self , mocked , tmp_path , progress , flag ):
499
512
runner = ct .CliRunner (mix_stderr = False )
500
513
result = runner .invoke (
501
- cli .vcf2zarr_main , f"dencode-finalise { tmp_path } " , catch_exceptions = False
514
+ cli .vcf2zarr_main ,
515
+ f"dencode-finalise { tmp_path } { flag } " ,
516
+ catch_exceptions = False ,
502
517
)
503
518
assert result .exit_code == 0
504
519
assert len (result .stdout ) == 0
505
520
assert len (result .stderr ) == 0
506
- mocked .assert_called_once_with (str (tmp_path ), ** DEFAULT_DENCODE_FINALISE_ARGS )
521
+ args = DEFAULT_DENCODE_FINALISE_ARGS
522
+ args ["show_progress" ] = progress
523
+ mocked .assert_called_once_with (str (tmp_path ), ** args )
507
524
525
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
508
526
@mock .patch ("bio2zarr.vcf2zarr.convert" )
509
- def test_convert_vcf (self , mocked ):
527
+ def test_convert_vcf (self , mocked , progress , flag ):
510
528
runner = ct .CliRunner (mix_stderr = False )
511
529
result = runner .invoke (
512
530
cli .vcf2zarr_main ,
513
- f"convert { self .vcf_path } zarr_path" ,
531
+ f"convert { self .vcf_path } zarr_path { flag } " ,
514
532
catch_exceptions = False ,
515
533
)
516
534
assert result .exit_code == 0
517
535
assert len (result .stdout ) == 0
518
536
assert len (result .stderr ) == 0
537
+ args = dict (DEFAULT_CONVERT_ARGS )
538
+ args ["show_progress" ] = progress
519
539
mocked .assert_called_once_with (
520
540
(self .vcf_path ,),
521
541
"zarr_path" ,
522
- ** DEFAULT_CONVERT_ARGS ,
542
+ ** args ,
523
543
)
524
544
525
545
@pytest .mark .parametrize ("response" , ["n" , "N" , "No" ])
@@ -538,16 +558,19 @@ def test_vcf_convert_overwrite_zarr_confirm_no(self, mocked, tmp_path, response)
538
558
assert "Aborted" in result .stderr
539
559
mocked .assert_not_called ()
540
560
561
+ @pytest .mark .parametrize (("progress" , "flag" ), [(True , "-P" ), (False , "-Q" )])
541
562
@mock .patch ("bio2zarr.plink.convert" )
542
- def test_convert_plink (self , mocked ):
563
+ def test_convert_plink (self , mocked , progress , flag ):
543
564
runner = ct .CliRunner (mix_stderr = False )
544
565
result = runner .invoke (
545
- cli .plink2zarr , ["convert" , "in" , "out" ], catch_exceptions = False
566
+ cli .plink2zarr , ["convert" , "in" , "out" , flag ], catch_exceptions = False
546
567
)
547
568
assert result .exit_code == 0
548
569
assert len (result .stdout ) == 0
549
570
assert len (result .stderr ) == 0
550
- mocked .assert_called_once_with ("in" , "out" , ** DEFAULT_CONVERT_ARGS )
571
+ args = dict (DEFAULT_CONVERT_ARGS )
572
+ args ["show_progress" ] = progress
573
+ mocked .assert_called_once_with ("in" , "out" , ** args )
551
574
552
575
@pytest .mark .parametrize ("response" , ["y" , "Y" , "yes" ])
553
576
@mock .patch ("bio2zarr.vcf2zarr.convert" )
@@ -578,10 +601,11 @@ def test_dexplode(self, tmp_path, one_based):
578
601
runner = ct .CliRunner (mix_stderr = False )
579
602
result = runner .invoke (
580
603
cli .vcf2zarr_main ,
581
- f"dexplode-init { self .vcf_path } { icf_path } 5 --json" ,
604
+ f"dexplode-init { self .vcf_path } { icf_path } 5 --json -Q " ,
582
605
catch_exceptions = False ,
583
606
)
584
607
assert result .exit_code == 0
608
+ assert len (result .stderr ) == 0
585
609
assert json .loads (result .stdout )["num_partitions" ] == 3
586
610
587
611
for j in range (3 ):
@@ -595,6 +619,7 @@ def test_dexplode(self, tmp_path, one_based):
595
619
cli .vcf2zarr_main , f"dexplode-finalise { icf_path } " , catch_exceptions = False
596
620
)
597
621
assert result .exit_code == 0
622
+ assert len (result .stderr ) == 0
598
623
599
624
result = runner .invoke (
600
625
cli .vcf2zarr_main , f"inspect { icf_path } " , catch_exceptions = False
0 commit comments