@@ -387,3 +387,46 @@ def test_serve_command_with_reload(runner, test_site_module, monkeypatch):
387387
388388 assert result .exit_code == 0 , result .output
389389 mock_get_paths .assert_called_once_with (mock_site )
390+
391+
392+ @pytest .mark .parametrize (
393+ "params, expected" ,
394+ [
395+ ([], ["console" , "html" ]),
396+ (["-x" ], ["console" , "xml" ]),
397+ (["-x" , "-o" , "sitemap.xml" ], ["file" , "xml" ]),
398+ (["-o" , "sitemap.html" ], ["file" , "html" ]),
399+ ],
400+ )
401+ def test_sitemap (runner , test_site_module , monkeypatch , params , expected ):
402+ """Tests sitemap generation command"""
403+
404+ class MockSiteMap :
405+ def __init__ (self , * args , ** kwargs ): ...
406+
407+ @property
408+ def html (self ):
409+ return "sitemap"
410+
411+ class MockPage :
412+ def __init__ (self , * args , ** kwargs ): ...
413+
414+ def _render_content (self , * args , ** kwargs ):
415+ return "sitemap"
416+
417+ with (
418+ patch ("render_engine_cli.cli.get_site" ) as mock_get_site ,
419+ ):
420+ monkeypatch .setattr ("render_engine_cli.cli.SiteMap" , MockSiteMap )
421+ monkeypatch .setattr ("render_engine_cli.cli.Page" , MockPage )
422+ mock_site = Mock ()
423+ mock_get_site .return_value = mock_site
424+ with runner .isolated_filesystem ():
425+ result = runner .invoke (app , ["sitemap" , "--module-site" , "test:test" , * params ])
426+ output_loc , output_type = expected
427+ expected_out = f"sitemap.{ output_type } "
428+ match output_loc :
429+ case "console" :
430+ assert result .output .strip () == "sitemap"
431+ case "file" :
432+ assert Path (expected_out ).read_text ().strip () == "sitemap"
0 commit comments