Skip to content

Commit 72956bf

Browse files
committed
add tests
1 parent c228703 commit 72956bf

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

test_minsert.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
# pylint: skip-file
4+
5+
from minsert.minsert import MarkdownFile, is_comment, is_ender, is_starter
6+
7+
8+
def test_is_comment():
9+
assert is_comment("<!-- -->")
10+
assert is_comment("<!-- hello how are you -->")
11+
assert is_comment("<!-- -->")
12+
assert not is_comment("< !-- -->")
13+
assert not is_comment("<!-- -- >")
14+
15+
16+
def test_is_starter():
17+
assert not is_starter("<!-- start -->")
18+
assert is_starter("<!-- start block -->") == "block"
19+
assert not is_starter("Normal Sentence")
20+
21+
22+
def test_is_ender():
23+
assert is_ender("<!-- end -->")
24+
assert is_ender("<!-- end blah blah-->")
25+
assert is_ender("<!-- blah end blah-->")
26+
assert not is_ender("end")
27+
assert not is_ender("<!-- blend -->")
28+
29+
30+
def test_minsert():
31+
with open("test.md", "w") as file:
32+
file.write("Hello\n<!-- start block-->\n<!-- end -->\nOk bye")
33+
mfile = MarkdownFile("test.md")
34+
mfile.insert({"block": "what"})
35+
with open("test.md") as file:
36+
content = file.read()
37+
assert content == "Hello\n<!-- start block-->\nwhat\n<!-- end -->\nOk bye"

0 commit comments

Comments
 (0)