|
1 | 1 | import pytest |
2 | | -from convert_docs import to_mkdocs, to_github |
| 2 | +from convert_docs import to_mkdocs |
3 | 3 |
|
4 | 4 | # --- 1. A2UI Specific Header Cases --- |
5 | 5 | ADMONITION_CASES = [ |
6 | | - ('!!! info "Coming soon..."', "Coming soon..."), |
7 | | - ('!!! warning "Status: Early Stage Public Preview"', "Status: Early Stage Public Preview"), |
8 | | - ('!!! success "Stable Release"', "Stable Release"), |
9 | | - ('!!! note "Version Compatibility"', "Version Compatibility"), |
10 | | - ('!!! warning "Attention"', "Attention"), |
11 | | - ('!!! tip "It\'s Just JSON"', "It's Just JSON"), |
| 6 | + ('!!! info "Coming soon..."', "Coming soon...", "ℹ️"), |
| 7 | + ('!!! warning "Status: Early Stage Public Preview"', "Status: Early Stage Public Preview", "⚠️"), |
| 8 | + ('!!! success "Stable Release"', "Stable Release", "✅"), |
| 9 | + ('!!! note "Version Compatibility"', "Version Compatibility", "📝"), |
| 10 | + ('!!! warning "Attention"', "Attention", "⚠️"), |
| 11 | + ('!!! tip "It\'s Just JSON"', "It's Just JSON", "💡"), |
12 | 12 | ] |
13 | 13 |
|
14 | | -@pytest.mark.parametrize("header, expected_title", ADMONITION_CASES) |
15 | | -def test_standard_a2ui_round_trip(header, expected_title): |
16 | | - """Verifies that all standard A2UI headers survive a round-trip conversion.""" |
| 14 | +@pytest.mark.parametrize("expected_header, title, emoji", ADMONITION_CASES) |
| 15 | +def test_standard_a2ui_conversion(expected_header, title, emoji): |
| 16 | + """Verifies that GitHub style converts to expected A2UI headers.""" |
17 | 17 | body = " Line 1\n Line 2" |
18 | | - original = f"{header}\n{body}\n" |
| 18 | + github_input = f"> {emoji} **{title}**\n>\n> Line 1\n> Line 2\n" |
19 | 19 |
|
20 | | - # MkDocs -> GitHub |
21 | | - github = to_github(original) |
22 | | - assert f"**{expected_title}**" in github |
| 20 | + expected = f"{expected_header}\n{body}\n" |
23 | 21 |
|
24 | 22 | # GitHub -> MkDocs |
25 | | - back = to_mkdocs(github) |
26 | | - assert back.strip() == original.strip() |
| 23 | + result = to_mkdocs(github_input) |
| 24 | + assert result.strip() == expected.strip() |
27 | 25 |
|
28 | 26 |
|
29 | 27 | # --- 2. Empty Title Edge Case --- |
30 | 28 | def test_empty_title_case(): |
31 | 29 | """ |
32 | | - Verifies !!! tip "" converts to '> 💡' exactly. |
33 | | - - No trailing spaces |
34 | | - - No bold markers (****) |
| 30 | + Verifies '> 💡' converts to !!! tip "". |
35 | 31 | """ |
36 | | - original = '!!! tip ""\n Content.\n' |
37 | | - github = to_github(original) |
| 32 | + github_input = "> 💡\n>\n> Content.\n" |
| 33 | + expected = '!!! tip ""\n Content.\n' |
38 | 34 |
|
39 | | - lines = github.splitlines() |
40 | | - assert lines[0] == "> 💡" # Strictly no space or bold markers |
41 | | - assert lines[1] == ">" # Spacer line |
42 | | - |
43 | | - back = to_mkdocs(github) |
44 | | - assert back == original |
| 35 | + result = to_mkdocs(github_input) |
| 36 | + assert result == expected |
45 | 37 |
|
46 | 38 |
|
47 | 39 | # --- 3. Spacing & Internal Paragraph Preservation --- |
@@ -73,49 +65,37 @@ def test_paragraph_spacing_and_trailing_lines(): |
73 | 65 | assert result == expected |
74 | 66 |
|
75 | 67 |
|
76 | | -# --- 4. Unmapped/Unknown Type Fallback --- |
77 | | -def test_unknown_type_fallback(): |
78 | | - """ |
79 | | - Verifies that an unknown admonition type defaults to the 'note' emoji (📝). |
80 | | - """ |
81 | | - original = '!!! mystery "Secret"\n Content.\n' |
82 | | - github = to_github(original) |
83 | | - |
84 | | - assert "> 📝 **Secret**" in github |
85 | | - |
86 | | - # Note: Round trip will convert it back to '!!! note' |
87 | | - # because the source type 'mystery' wasn't in the map. |
88 | | - back = to_mkdocs(github) |
89 | | - assert '!!! note "Secret"' in back |
90 | | - |
91 | | - |
92 | | -# --- 5. Multiple Blocks & Isolation --- |
| 68 | +# --- 4. Multiple Blocks & Isolation --- |
93 | 69 | def test_multiple_blocks_in_one_file(): |
94 | 70 | """Ensures multiple blocks are processed without bleeding into each other.""" |
95 | | - original = ( |
| 71 | + github_input = ( |
| 72 | + '> ✅ **Block 1**\n' |
| 73 | + '> Content 1\n' |
| 74 | + '\n' |
| 75 | + '> ℹ️ **Block 2**\n' |
| 76 | + '> Content 2\n' |
| 77 | + ) |
| 78 | + |
| 79 | + expected = ( |
96 | 80 | '!!! success "Block 1"\n' |
97 | 81 | ' Content 1\n' |
98 | 82 | '\n' |
99 | 83 | '!!! info "Block 2"\n' |
100 | 84 | ' Content 2\n' |
101 | 85 | ) |
102 | | - github = to_github(original) |
103 | | - assert "> ✅ **Block 1**" in github |
104 | | - assert "> ℹ️ **Block 2**" in github |
105 | 86 |
|
106 | | - back = to_mkdocs(github) |
107 | | - assert back == original |
| 87 | + result = to_mkdocs(github_input) |
| 88 | + assert result == expected |
108 | 89 |
|
109 | 90 |
|
110 | | -# --- 6. False Positive Prevention --- |
| 91 | +# --- 5. False Positive Prevention --- |
111 | 92 | def test_regular_blockquote_ignored(): |
112 | 93 | """Ensures regular quotes are not touched.""" |
113 | 94 | source = "> This is just a quote, not an admonition." |
114 | 95 | assert to_mkdocs(source) == source |
115 | | - assert to_github(source) == source |
116 | 96 |
|
117 | 97 |
|
118 | | -# --- 7. GitHub Official Alert Syntax Support --- |
| 98 | +# --- 6. GitHub Official Alert Syntax Support --- |
119 | 99 | def test_github_alert_to_mkdocs(): |
120 | 100 | """Verifies official [!TYPE] syntax conversion.""" |
121 | 101 | source = "> [!WARNING]\n> **Security Notice**\n> Do not share keys." |
|
0 commit comments