@@ -62,9 +62,11 @@ def test_make_script(
6262
6363
6464@pytest .mark .parametrize ("specify_dir" , [False , True ])
65+ @pytest .mark .parametrize ("specify_env" , [False , True ])
6566@patch ("xcengine.cli.ImageBuilder" )
66- def test_image_build (builder_mock , tmp_path , specify_dir ):
67+ def test_image_build (builder_mock , tmp_path , specify_dir , specify_env ):
6768 (nb_path := tmp_path / "foo.ipynb" ).touch ()
69+ (env_path := tmp_path / "environment.yml" ).touch ()
6870 (build_dir := tmp_path / "build" ).mkdir ()
6971 runner = CliRunner ()
7072 tag = "foo"
@@ -73,13 +75,14 @@ def test_image_build(builder_mock, tmp_path, specify_dir):
7375 cli ,
7476 ["image" , "build" , "--tag" , tag ]
7577 + (["--build-dir" , str (build_dir )] if specify_dir else [])
78+ + (["--environment" , str (env_path )] if specify_env else [])
7679 + [str (nb_path )],
7780 )
7881 assert result .output .startswith ("Built image" )
7982 assert result .exit_code == 0
8083 builder_mock .assert_called_once_with (
8184 notebook = nb_path ,
82- environment = None ,
85+ environment = ( env_path if specify_env else None ) ,
8386 tag = tag ,
8487 build_dir = (build_dir if specify_dir else ANY ),
8588 )
0 commit comments