X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/blobdiff_plain/f64a954a8596d88ee77707d2c42892aba161b385..65fd4f767aa95e8da1ff83c16f82223740611fd6:/tests/test_mwmarkup.py
diff --git a/tests/test_mwmarkup.py b/tests/test_mwmarkup.py
index a1fa937..3d8c2cb 100644
--- a/tests/test_mwmarkup.py
+++ b/tests/test_mwmarkup.py
@@ -82,3 +82,50 @@ 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 = u'''
+
+ (Parkplatz)47.114958,11.266026
+ Erster Parkplatz
+
+ (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
+ 6#FF014E9A
+ 47.114715,11.266262
+ 47.114135,11.268381
+ 47.113421,11.269322
+ 47.11277,11.269979
+ 47.112408,11.271119
+
+ '''
+ center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
+ assert center == (11.272337, 47.113291)
+ assert zoom == 15
+ assert coords == [
+ (11.266026, 47.114958, 'Parkplatz', 'Erster Parkplatz'),
+ (11.266262, 47.114715, 'Gasthaus', u'Alt Bärnbad (Gasthaus)')]
+ assert paths == [
+ ('6#FF014E9A', [
+ (11.266262, 47.114715, None, None),
+ (11.268381, 47.114135, None, None),
+ (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('