Coverage for tests / unit / views / test_markdown.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-16 21:32 +0000

1from pathlib import Path 

2from unittest.mock import mock_open, patch 

3 

4from graphable.views.markdown import export_markdown_wrapped, wrap_in_markdown 

5 

6 

7class TestMarkdown: 

8 def test_wrap_in_markdown(self): 

9 content = "graph definition" 

10 wrapped = wrap_in_markdown(content, "mermaid") 

11 

12 assert "```mermaid" in wrapped 

13 assert content in wrapped 

14 assert "```" in wrapped 

15 

16 def test_export_markdown_wrapped(self): 

17 content = "content" 

18 output_path = Path("output.md") 

19 

20 with patch("builtins.open", mock_open()) as mock_file: 

21 export_markdown_wrapped(content, "d2", output_path) 

22 

23 mock_file.assert_called_with(output_path, "w+") 

24 mock_file().write.assert_called()