@@ -754,6 +754,66 @@ def test_tskit_convert_with_options(self, mocked, tmp_path):
754
754
** expected_args ,
755
755
)
756
756
757
+ @pytest .mark .parametrize ("response" , ["y" , "Y" , "yes" ])
758
+ @mock .patch ("bio2zarr.plink.convert" )
759
+ def test_plink_convert_overwrite_zarr_confirm_yes (self , mocked , tmp_path , response ):
760
+ prefix = "tests/data/plink/example"
761
+ zarr_path = tmp_path / "zarr"
762
+ zarr_path .mkdir ()
763
+ runner = ct .CliRunner ()
764
+ result = runner .invoke (
765
+ cli .plink2zarr_main ,
766
+ f"convert { prefix } { zarr_path } " ,
767
+ catch_exceptions = False ,
768
+ input = response ,
769
+ )
770
+ assert result .exit_code == 0
771
+ assert f"Do you want to overwrite { zarr_path } " in result .stdout
772
+ assert len (result .stderr ) == 0
773
+ mocked .assert_called_once_with (
774
+ prefix ,
775
+ str (zarr_path ),
776
+ ** DEFAULT_PLINK_CONVERT_ARGS ,
777
+ )
778
+
779
+ @pytest .mark .parametrize ("response" , ["n" , "N" , "No" ])
780
+ @mock .patch ("bio2zarr.plink.convert" )
781
+ def test_plink_convert_overwrite_zarr_confirm_no (self , mocked , tmp_path , response ):
782
+ prefix = "tests/data/plink/example"
783
+ zarr_path = tmp_path / "zarr"
784
+ zarr_path .mkdir ()
785
+ runner = ct .CliRunner ()
786
+ result = runner .invoke (
787
+ cli .plink2zarr_main ,
788
+ f"convert { prefix } { zarr_path } " ,
789
+ catch_exceptions = False ,
790
+ input = response ,
791
+ )
792
+ assert result .exit_code == 1
793
+ assert "Aborted" in result .stderr
794
+ mocked .assert_not_called ()
795
+
796
+ @pytest .mark .parametrize ("force_arg" , ["-f" , "--force" ])
797
+ @mock .patch ("bio2zarr.plink.convert" )
798
+ def test_plink_convert_overwrite_zarr_force (self , mocked , tmp_path , force_arg ):
799
+ prefix = "tests/data/plink/example"
800
+ zarr_path = tmp_path / "zarr"
801
+ zarr_path .mkdir ()
802
+ runner = ct .CliRunner ()
803
+ result = runner .invoke (
804
+ cli .plink2zarr_main ,
805
+ f"convert { prefix } { zarr_path } { force_arg } " ,
806
+ catch_exceptions = False ,
807
+ )
808
+ assert result .exit_code == 0
809
+ assert len (result .stdout ) == 0
810
+ assert len (result .stderr ) == 0
811
+ mocked .assert_called_once_with (
812
+ prefix ,
813
+ str (zarr_path ),
814
+ ** DEFAULT_PLINK_CONVERT_ARGS ,
815
+ )
816
+
757
817
758
818
class TestVcfEndToEnd :
759
819
vcf_path = "tests/data/vcf/sample.vcf.gz"
0 commit comments