X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/blobdiff_plain/1fec94cdbfe9c1d3bb760de7fc5b324fd364ad97..65fd4f767aa95e8da1ff83c16f82223740611fd6:/tests/test_mwmarkup.py diff --git a/tests/test_mwmarkup.py b/tests/test_mwmarkup.py index 97feef3..3d8c2cb 100644 --- a/tests/test_mwmarkup.py +++ b/tests/test_mwmarkup.py @@ -82,8 +82,21 @@ def test_create_template(): assert wikitext_generated == wikitext +def test_find_tag(): + wikitext = u'This is my first tag and my second tag.' + start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tags') + assert (start, content, endtag, end) == (None, None, None, None) + start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag') + assert (start, content, endtag, end) == (8, 13, 25, 31) + start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag', end) + assert (start, content, endtag, end) == (36, 41, 54, 60) + wikitext = u'This is .' + start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag') + assert (start, content, endtag, end) == (8, None, None, 27) + + def test_parse_googlemap(): - wikitext = ''' + wikitext = u''' (Parkplatz)47.114958,11.266026 Erster Parkplatz @@ -102,7 +115,7 @@ def test_parse_googlemap(): assert zoom == 15 assert coords == [ (11.266026, 47.114958, 'Parkplatz', 'Erster Parkplatz'), - (11.266262, 47.114715, 'Gasthaus', 'Alt Bärnbad (Gasthaus)')] + (11.266262, 47.114715, 'Gasthaus', u'Alt Bärnbad (Gasthaus)')] assert paths == [ ('6#FF014E9A', [ (11.266262, 47.114715, None, None), @@ -110,3 +123,9 @@ def test_parse_googlemap(): (11.269322, 47.113421, None, None), (11.269979, 47.11277, None, None), (11.271119, 47.112408, None, None)])] + center, zoom, coords, paths, start, end = wrpylib.mwmarkup.parse_googlemap(wikitext, detail=True) + assert start == 5 + assert end == 344 + result = wrpylib.mwmarkup.parse_googlemap(wikitext.replace('