46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"test des kleinen Wiki Systems"
|
|
import pytest
|
|
import wiki
|
|
|
|
@pytest.fixture
|
|
def pages():
|
|
w=wiki.PageManager(file="")
|
|
w.from_dict({
|
|
"home": {},
|
|
"home/hello":{},
|
|
"home/hello2":{"path":"homehello"}
|
|
})
|
|
return w
|
|
|
|
class TestPageAttribute:
|
|
def test_id(self,pages):
|
|
assert pages["home"].id=="home"
|
|
|
|
|
|
def test_page_hello(pages):
|
|
assert isinstance(pages["home"],wiki.Page)
|
|
|
|
class TestPageParsing:
|
|
def test_leave_html(self):
|
|
t="<b>Hello</b><ul><li>sf</li></ul>"
|
|
tout, entities=wiki.parse_intern_page(t)
|
|
assert t==tout
|
|
|
|
def test_replacebrakcets_html(self):
|
|
t="<b>Hello</b><ul><li>[uj]</li></ul>"
|
|
tout, entities=wiki.parse_intern_page(t)
|
|
assert not t==tout
|
|
assert tout=='<b>Hello</b><ul><li><a href="/wiki/uj">uj</a></li></ul>'
|
|
|
|
def test_replace_tags_html(self):
|
|
t="<b>Hello</b><ul><li>#uj</li></ul>"
|
|
tout, entities=wiki.parse_intern_page(t)
|
|
assert not t==tout
|
|
assert tout=='<b>Hello</b><ul><li><a href="/tag/uj">#uj</a></li></ul>'
|
|
|
|
def test_replace_tags_inentities(self):
|
|
t="<b>Hello</b><ul><li>#uj</li></ul>"
|
|
tout, entities=wiki.parse_intern_page(t)
|
|
assert "uj" in entities["tags"]
|
|
|
|
|