@@ -32,7 +32,7 @@ def mock_click_echo(mocker):
32
32
33
33
@pytest .fixture
34
34
def mock_project_path (mocker ):
35
- mock_path = "/tmp/project_path"
35
+ mock_path = Path ( "/tmp/project_path" )
36
36
mocker .patch ("pathlib.Path.cwd" , return_value = mock_path )
37
37
return mock_path
38
38
@@ -259,6 +259,45 @@ def test_kedro_viz_command_should_log_project_not_found(
259
259
260
260
mock_click_echo .assert_has_calls (mock_click_echo_calls )
261
261
262
+ def test_kedro_viz_command_logs_hooks_message (
263
+ self , mocker , mock_project_path , mock_click_echo
264
+ ):
265
+ """
266
+ Test that Kedro-Viz logs the correct message when
267
+ the `--include-hooks` flag is used or omitted.
268
+ """
269
+ # Mock server setup and readiness checks
270
+ mocker .patch ("kedro_viz.server.run_server" )
271
+ mocker .patch (
272
+ "kedro_viz.launchers.utils._wait_for.__defaults__" , (True , 1 , True , 1 )
273
+ )
274
+ mocker .patch (
275
+ "kedro_viz.launchers.utils._find_kedro_project" ,
276
+ return_value = mock_project_path ,
277
+ )
278
+
279
+ runner = CliRunner ()
280
+
281
+ # Test with --include-hooks
282
+ with runner .isolated_filesystem ():
283
+ runner .invoke (main .viz_cli , ["viz" , "run" , "--include-hooks" ])
284
+
285
+ assert any (
286
+ "INFO: Running Kedro-Viz with hooks." in call .args [0 ]
287
+ for call in mock_click_echo .mock_calls
288
+ ), "Expected message about running with hooks not found."
289
+
290
+ # Test without --include-hooks
291
+ with runner .isolated_filesystem ():
292
+ runner .invoke (main .viz_cli , ["viz" , "run" ])
293
+
294
+ assert any (
295
+ "INFO: Running Kedro-Viz without hooks. "
296
+ "Try `kedro viz run --include-hooks` to include hook functionality."
297
+ in call .args [0 ]
298
+ for call in mock_click_echo .mock_calls
299
+ ), "Expected message about running without hooks not found."
300
+
262
301
def test_kedro_viz_command_should_log_outdated_version (
263
302
self , mocker , mock_http_response , mock_click_echo , mock_project_path
264
303
):
0 commit comments