#!/usr/bin/python2.7
# -*- coding: iso-8859-15 -*-
+import unittest
import wrpylib.mwdb
import sqlalchemy
-def test_page_table():
- metadata = sqlalchemy.MetaData()
- page_table = wrpylib.mwdb.page_table(metadata)
+class TestMwDb(unittest.TestCase):
+ def test_page_table(self):
+ metadata = sqlalchemy.MetaData()
+ page_table = wrpylib.mwdb.page_table(metadata)
-def test_revision_table():
- metadata = sqlalchemy.MetaData()
- revision_table = wrpylib.mwdb.revision_table(metadata)
+ def test_revision_table(self):
+ metadata = sqlalchemy.MetaData()
+ revision_table = wrpylib.mwdb.revision_table(metadata)
-def test_text_table():
- metadata = sqlalchemy.MetaData()
- text_table = wrpylib.mwdb.text_table(metadata)
+ def test_text_table(self):
+ metadata = sqlalchemy.MetaData()
+ text_table = wrpylib.mwdb.text_table(metadata)
-def test_categorylinks_table():
- metadata = sqlalchemy.MetaData()
- categorylinks_table = wrpylib.mwdb.categorylinks_table(metadata)
+ def test_categorylinks_table(self):
+ metadata = sqlalchemy.MetaData()
+ categorylinks_table = wrpylib.mwdb.categorylinks_table(metadata)
#!/usr/bin/python2.7
# -*- coding: iso-8859-15 -*-
import wrpylib.mwmarkup
+import unittest
-def test_find_template():
- wikitext = u'''== Allgemeines ==
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Gehzeit = 105
- | Aufstieg getrennt = Nein
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}
- Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
- assert start == wikitext.find(u'{{')
- assert end == wikitext.find(u'}}')+2
+class TestMwMarkup(unittest.TestCase):
+ def test_find_template(self):
+ wikitext = u'''== Allgemeines ==
+ {{Rodelbahnbox
+ | Position = 47.309820 N 9.986508 E
+ | Position oben =
+ | Höhe oben = 1244
+ | Position unten =
+ | Höhe unten = 806
+ | Länge = 5045
+ | Schwierigkeit =
+ | Lawinen = gelegentlich
+ | Betreiber =
+ | Öffentliche Anreise = Ja
+ | Gehzeit = 105
+ | Aufstieg getrennt = Nein
+ | Aufstiegshilfe = Nein
+ | Beleuchtungsanlage = Nein
+ | Beleuchtungstage =
+ | Rodelverleih = Ja
+ | Gütesiegel =
+ | Webauskunft =
+ | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
+ | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
+ | In Übersichtskarte = Ja
+ | Forumid = 72
+ }}
+ Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
+ start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
+ assert start == wikitext.find(u'{{')
+ assert end == wikitext.find(u'}}')+2
-def test_TemplateValidator():
- v = wrpylib.mwmarkup.TemplateValidator()
- value = u'{{Rodelbahnbox | Unbenannt | Position = 47.309820 N 9.986508 E | Aufstieg möglich = Ja }}'
- title, anonym_params, named_params = v.to_python(value)
- assert title == u'Rodelbahnbox'
- assert anonym_params == [u'Unbenannt']
- assert named_params.keys() == [u'Position', u'Aufstieg möglich']
- assert named_params.values() == ['47.309820 N 9.986508 E', 'Ja']
- value2 = v.from_python((title, anonym_params, named_params))
- assert value2 == u'{{Rodelbahnbox|Unbenannt|Position=47.309820 N 9.986508 E|Aufstieg möglich=Ja}}'
- v = wrpylib.mwmarkup.TemplateValidator(as_table=True)
- value3 = v.from_python((title, anonym_params, named_params))
- print value3
- assert value3 == \
- u'{{Rodelbahnbox\n' + \
- u'| Unbenannt\n' + \
- u'| Position = 47.309820 N 9.986508 E\n' + \
- u'| Aufstieg möglich = Ja\n' + \
- u'}}'
- v = wrpylib.mwmarkup.TemplateValidator(strip=False)
- title, anonym_params, named_params = v.to_python(value)
- assert title == u'Rodelbahnbox '
- assert anonym_params == [u' Unbenannt ']
- assert named_params.keys() == [u' Position ', u' Aufstieg möglich ']
- assert named_params.values() == [' 47.309820 N 9.986508 E ', ' Ja ']
+ def test_TemplateValidator(self):
+ v = wrpylib.mwmarkup.TemplateValidator()
+ value = u'{{Rodelbahnbox | Unbenannt | Position = 47.309820 N 9.986508 E | Aufstieg möglich = Ja }}'
+ title, anonym_params, named_params = v.to_python(value)
+ assert title == u'Rodelbahnbox'
+ assert anonym_params == [u'Unbenannt']
+ assert named_params.keys() == [u'Position', u'Aufstieg möglich']
+ assert named_params.values() == ['47.309820 N 9.986508 E', 'Ja']
+ value2 = v.from_python((title, anonym_params, named_params))
+ assert value2 == u'{{Rodelbahnbox|Unbenannt|Position=47.309820 N 9.986508 E|Aufstieg möglich=Ja}}'
+ v = wrpylib.mwmarkup.TemplateValidator(as_table=True)
+ value3 = v.from_python((title, anonym_params, named_params))
+ assert value3 == \
+ u'{{Rodelbahnbox\n' + \
+ u'| Unbenannt\n' + \
+ u'| Position = 47.309820 N 9.986508 E\n' + \
+ u'| Aufstieg möglich = Ja\n' + \
+ u'}}'
+ v = wrpylib.mwmarkup.TemplateValidator(strip=False)
+ title, anonym_params, named_params = v.to_python(value)
+ assert title == u'Rodelbahnbox '
+ assert anonym_params == [u' Unbenannt ']
+ assert named_params.keys() == [u' Position ', u' Aufstieg möglich ']
+ assert named_params.values() == [' 47.309820 N 9.986508 E ', ' Ja ']
-def test_split_template():
- wikitext = u'''== Allgemeines ==
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Gehzeit = 105
- | Aufstieg getrennt = Nein
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}
- Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
- template_title, parameters = wrpylib.mwmarkup.split_template(wikitext[start:end])
- assert template_title == u'Rodelbahnbox'
- assert len(parameters) == 22
- assert parameters['Position'] == u'47.309820 N 9.986508 E'
- assert parameters['Telefonauskunft'] == u'+43-664-1808482 (Bergkristallhütte)'
- assert parameters['Schwierigkeit'] == u''
+ def test_split_template(self):
+ wikitext = u'''== Allgemeines ==
+ {{Rodelbahnbox
+ | Position = 47.309820 N 9.986508 E
+ | Position oben =
+ | Höhe oben = 1244
+ | Position unten =
+ | Höhe unten = 806
+ | Länge = 5045
+ | Schwierigkeit =
+ | Lawinen = gelegentlich
+ | Betreiber =
+ | Öffentliche Anreise = Ja
+ | Gehzeit = 105
+ | Aufstieg getrennt = Nein
+ | Aufstiegshilfe = Nein
+ | Beleuchtungsanlage = Nein
+ | Beleuchtungstage =
+ | Rodelverleih = Ja
+ | Gütesiegel =
+ | Webauskunft =
+ | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
+ | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
+ | In Übersichtskarte = Ja
+ | Forumid = 72
+ }}
+ Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
+ start, end = wrpylib.mwmarkup.find_template(wikitext, u'Rodelbahnbox')
+ template_title, parameters = wrpylib.mwmarkup.split_template(wikitext[start:end])
+ assert template_title == u'Rodelbahnbox'
+ assert len(parameters) == 22
+ assert parameters['Position'] == u'47.309820 N 9.986508 E'
+ assert parameters['Telefonauskunft'] == u'+43-664-1808482 (Bergkristallhütte)'
+ assert parameters['Schwierigkeit'] == u''
-def test_create_template():
- wikitext = u'''{{Nicetemplate|Red|Bold|Position=Top|Alignment=Right}}'''
- template_title, parameters = wrpylib.mwmarkup.split_template(wikitext)
- print parameters
- keys = [u'1', u'2', u'Position', u'Alignment']
- values = [parameters[k] for k in keys]
- wikitext_generated = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:])
- wikitext_table = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:], True)
- assert wikitext_generated == wikitext
+ def test_create_template(self):
+ wikitext = u'''{{Nicetemplate|Red|Bold|Position=Top|Alignment=Right}}'''
+ template_title, parameters = wrpylib.mwmarkup.split_template(wikitext)
+ keys = [u'1', u'2', u'Position', u'Alignment']
+ values = [parameters[k] for k in keys]
+ wikitext_generated = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:])
+ wikitext_table = wrpylib.mwmarkup.create_template(template_title, values[:2], keys[2:], values[2:], True)
+ assert wikitext_generated == wikitext
-def test_find_tag():
- wikitext = u'This is <tag>my first tag</tag> and <tag>my second tag</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 <tag myattrib="4"/>.'
- start, content, endtag, end = wrpylib.mwmarkup.find_tag(wikitext, u'tag')
- assert (start, content, endtag, end) == (8, None, None, 27)
+ def test_find_tag(self):
+ wikitext = u'This is <tag>my first tag</tag> and <tag>my second tag</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 <tag myattrib="4"/>.'
+ 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'''
- <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
- (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
- </googlemap>
- '''
- attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
- assert attributes['lon'] == 11.272337
- assert attributes['lat'] == 47.113291
- assert attributes['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)])]
- try:
- result = wrpylib.mwmarkup.parse_googlemap(wikitext.replace('<googlemap', '|googlemap'))
- assert False
- except wrpylib.mwmarkup.ParseError:
- pass
+ def test_parse_googlemap(self):
+ wikitext = u'''
+ <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
+ (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
+ </googlemap>
+ '''
+ attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
+ assert attributes['lon'] == 11.272337
+ assert attributes['lat'] == 47.113291
+ assert attributes['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)])]
+ try:
+ result = wrpylib.mwmarkup.parse_googlemap(wikitext.replace('<googlemap', '|googlemap'))
+ assert False
+ except wrpylib.mwmarkup.ParseError:
+ pass
# This has been fixed in MySQL_python version 1.2.4.
import MySQLdb
import types
+import unittest
def exec_sql(sql):
return row
-def test_datatype_page():
- result = exec_sql('select page_title, page_restrictions, page_touched from page where page_id = 1321')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.StringType # tinyblob NOT NULL
- assert type(result[2]) == types.StringType # binary(14) NOT NULL
+class TestMySqlPython(unittest.TestCase):
+ def test_datatype_page(self):
+ result = exec_sql('select page_title, page_restrictions, page_touched from page where page_id = 1321')
+ assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == types.StringType # tinyblob NOT NULL
+ assert type(result[2]) == types.StringType # binary(14) NOT NULL
-def test_datatype_revision():
- result = exec_sql('select rev_comment, rev_user_text, rev_timestamp from revision where rev_id = 7586')
- assert type(result[0]) == types.StringType # tinyblob NOT NULL
- assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[2]) == types.StringType # binary(14) NOT NULL
+ def test_datatype_revision(self):
+ result = exec_sql('select rev_comment, rev_user_text, rev_timestamp from revision where rev_id = 7586')
+ assert type(result[0]) == types.StringType # tinyblob NOT NULL
+ assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[2]) == types.StringType # binary(14) NOT NULL
-def test_datatypes_text():
- result = exec_sql('select old_text, old_flags from text where old_id = 7438')
- assert type(result[0]) == types.StringType # mediumblob NOT NULL
- assert type(result[1]) == types.StringType # tinyblob NOT NULL
+ def test_datatypes_text(self):
+ result = exec_sql('select old_text, old_flags from text where old_id = 7438')
+ assert type(result[0]) == types.StringType # mediumblob NOT NULL
+ assert type(result[1]) == types.StringType # tinyblob NOT NULL
-def test_datatype_user():
- result = exec_sql('select user_name, user_real_name, user_email from user where user_id = 1')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[2]) == types.UnicodeType # tinytext NOT NULL
- assert result[0] == u'Philipp'
+ def test_datatype_user(self):
+ result = exec_sql('select user_name, user_real_name, user_email from user where user_id = 1')
+ assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[2]) == types.UnicodeType # tinytext NOT NULL
+ assert result[0] == u'Philipp'
-def test_datatype_categorylinks():
- result = exec_sql('select cl_to, cl_sortkey from categorylinks where cl_from = 609')
- assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
- assert type(result[1]) == types.StringType # varbinary(230) NOT NULL
+ def test_datatype_categorylinks(self):
+ result = exec_sql('select cl_to, cl_sortkey from categorylinks where cl_from = 609')
+ assert type(result[0]) == types.UnicodeType # varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
+ assert type(result[1]) == types.StringType # varbinary(230) NOT NULL
from sqlalchemy.engine import create_engine
from sqlalchemy.sql import select
from wrpylib import mwdb
+import unittest
def connect():
return connection
-def test_datatype_page():
- metadata = schema.MetaData()
- tpage = mwdb.page_table(metadata)
- page = connect().execute(select([tpage], tpage.c.page_id == 1321)).first()
- assert type(page.page_title) == types.UnicodeType
- assert type(page.page_restrictions) == types.StringType
- assert type(page.page_touched) == types.UnicodeType
-
-
-def test_datatype_revision():
- metadata = schema.MetaData()
- trevision = mwdb.revision_table(metadata)
- revision = connect().execute(select([trevision], trevision.c.rev_id == 7586)).first()
- assert type(revision.rev_comment) == types.UnicodeType
- assert type(revision.rev_user_text) == types.UnicodeType
- assert type(revision.rev_timestamp) == types.UnicodeType
-
-
-def test_datatypes_text():
- metadata = schema.MetaData()
- ttext = mwdb.text_table(metadata)
- text = connect().execute(select([ttext], ttext.c.old_id==7438)).first()
- assert type(text.old_text) == types.UnicodeType
- assert type(text.old_flags) == types.UnicodeType
- assert text.old_flags == u'utf-8'
-
-
-def test_datatype_user():
- metadata = schema.MetaData()
- tuser = mwdb.user_table(metadata)
- user = connect().execute(select([tuser], tuser.c.user_id == 1)).first()
- assert type(user.user_name) == types.UnicodeType
- assert type(user.user_real_name) == types.UnicodeType
- assert type(user.user_email) == types.UnicodeType
- assert user.user_name == u'Philipp'
-
-
-def test_datatype_categorylinks():
- metadata = schema.MetaData()
- tcategorylinks = mwdb.categorylinks_table(metadata)
- categorylinks = connect().execute(select([tcategorylinks], tcategorylinks.c.cl_from == 609)).first()
- assert type(categorylinks.cl_to) == types.UnicodeType
- assert type(categorylinks.cl_sortkey) == types.UnicodeType
- assert categorylinks.cl_sortkey == u'ALT BÄRNBAD'
+class TestSqlAlchemy(unittest.TestCase):
+ def test_datatype_page(self):
+ metadata = schema.MetaData()
+ tpage = mwdb.page_table(metadata)
+ page = connect().execute(select([tpage], tpage.c.page_id == 1321)).first()
+ assert type(page.page_title) == types.UnicodeType
+ assert type(page.page_restrictions) == types.StringType
+ assert type(page.page_touched) == types.UnicodeType
+
+
+ def test_datatype_revision(self):
+ metadata = schema.MetaData()
+ trevision = mwdb.revision_table(metadata)
+ revision = connect().execute(select([trevision], trevision.c.rev_id == 7586)).first()
+ assert type(revision.rev_comment) == types.UnicodeType
+ assert type(revision.rev_user_text) == types.UnicodeType
+ assert type(revision.rev_timestamp) == types.UnicodeType
+
+
+ def test_datatypes_text(self):
+ metadata = schema.MetaData()
+ ttext = mwdb.text_table(metadata)
+ text = connect().execute(select([ttext], ttext.c.old_id==7438)).first()
+ assert type(text.old_text) == types.UnicodeType
+ assert type(text.old_flags) == types.UnicodeType
+ assert text.old_flags == u'utf-8'
+
+
+ def test_datatype_user(self):
+ metadata = schema.MetaData()
+ tuser = mwdb.user_table(metadata)
+ user = connect().execute(select([tuser], tuser.c.user_id == 1)).first()
+ assert type(user.user_name) == types.UnicodeType
+ assert type(user.user_real_name) == types.UnicodeType
+ assert type(user.user_email) == types.UnicodeType
+ assert user.user_name == u'Philipp'
+
+
+ def test_datatype_categorylinks(self):
+ metadata = schema.MetaData()
+ tcategorylinks = mwdb.categorylinks_table(metadata)
+ categorylinks = connect().execute(select([tcategorylinks], tcategorylinks.c.cl_from == 609)).first()
+ assert type(categorylinks.cl_to) == types.UnicodeType
+ assert type(categorylinks.cl_sortkey) == types.UnicodeType
+ assert categorylinks.cl_sortkey == u'ALT BÄRNBAD'
# -*- coding: iso-8859-15 -*-
import wrpylib.wrmwdb
import sqlalchemy
+import unittest
-def test_wrreport_table():
- metadata = sqlalchemy.MetaData()
- wrreport_table = wrpylib.wrmwdb.wrreport_table(metadata)
+class TestWrMwDb(unittest.TestCase):
+ def test_wrreport_table(self):
+ metadata = sqlalchemy.MetaData()
+ wrreport_table = wrpylib.wrmwdb.wrreport_table(metadata)
-def test_wrsledruncache_table():
- metadata = sqlalchemy.MetaData()
- wrsledruncache_table = wrpylib.wrmwdb.wrsledruncache_table(metadata)
+ def test_wrsledruncache_table(self):
+ metadata = sqlalchemy.MetaData()
+ wrsledruncache_table = wrpylib.wrmwdb.wrsledruncache_table(metadata)
-def test_wrinncache_table():
- metadata = sqlalchemy.MetaData()
- wrinncache_table = wrpylib.wrmwdb.wrinncache_table(metadata)
+ def test_wrinncache_table(self):
+ metadata = sqlalchemy.MetaData()
+ wrinncache_table = wrpylib.wrmwdb.wrinncache_table(metadata)
import collections
import wrpylib.wrmwmarkup
import wrpylib.mwmarkup
-import formencode
import textwrap
+import unittest
-def test_rodelbahnbox_to_sledrun():
- wikitext = u'''== Allgemeines ==
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Gehzeit = 105
- | Aufstieg möglich = Nein
- | Aufstieg getrennt = Nein
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}
- Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
- wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun)
+class TestWrMwMarkup(unittest.TestCase):
+ def test_rodelbahnbox_to_sledrun(self):
+ wikitext = u'''== Allgemeines ==
+ {{Rodelbahnbox
+ | Position = 47.309820 N 9.986508 E
+ | Position oben =
+ | Höhe oben = 1244
+ | Position unten =
+ | Höhe unten = 806
+ | Länge = 5045
+ | Schwierigkeit =
+ | Lawinen = gelegentlich
+ | Betreiber =
+ | Öffentliche Anreise = Ja
+ | Gehzeit = 105
+ | Aufstieg möglich = Nein
+ | Aufstieg getrennt = Nein
+ | Aufstiegshilfe = Nein
+ | Beleuchtungsanlage = Nein
+ | Beleuchtungstage =
+ | Rodelverleih = Ja
+ | Gütesiegel =
+ | Webauskunft =
+ | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
+ | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
+ | In Übersichtskarte = Ja
+ | Forumid = 72
+ }}
+ Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
+ start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
+ wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun)
-def test_RodelbahnboxDictConverter():
- v = wrpylib.wrmwmarkup.RodelbahnboxDictConverter()
- other = collections.OrderedDict([
- (u'Position', (47.30982, 9.986508)),
- (u'Position oben', (None, None)),
- (u'Höhe oben', 1244),
- (u'Position unten', (None, None)),
- (u'Höhe unten', 806),
- (u'Länge', 5045),
- (u'Schwierigkeit', None),
- (u'Lawinen', 3),
- (u'Betreiber', None),
- (u'Öffentliche Anreise', 6),
- (u'Aufstieg möglich', True),
- (u'Aufstieg getrennt', (0.0, None)),
- (u'Gehzeit', 105),
- (u'Aufstiegshilfe', (False, None)),
- (u'Beleuchtungsanlage', (0.0, None)),
- (u'Beleuchtungstage', (None, None)),
- (u'Rodelverleih', (True, u'Ja')),
- (u'Gütesiegel', None),
- (u'Webauskunft', None),
- (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
- (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
- (u'In Übersichtskarte', True),
- (u'Forumid', 72)])
- sledrun = v.to_python(other)
- assert sledrun.forum_id == 72
- other2 = v.from_python(sledrun)
- assert other == other2
+ def test_RodelbahnboxDictConverter(self):
+ v = wrpylib.wrmwmarkup.RodelbahnboxDictConverter()
+ other = collections.OrderedDict([
+ (u'Position', (47.30982, 9.986508)),
+ (u'Position oben', (None, None)),
+ (u'Höhe oben', 1244),
+ (u'Position unten', (None, None)),
+ (u'Höhe unten', 806),
+ (u'Länge', 5045),
+ (u'Schwierigkeit', None),
+ (u'Lawinen', 3),
+ (u'Betreiber', None),
+ (u'Öffentliche Anreise', 6),
+ (u'Aufstieg möglich', True),
+ (u'Aufstieg getrennt', (0.0, None)),
+ (u'Gehzeit', 105),
+ (u'Aufstiegshilfe', (False, None)),
+ (u'Beleuchtungsanlage', (0.0, None)),
+ (u'Beleuchtungstage', (None, None)),
+ (u'Rodelverleih', (True, u'Ja')),
+ (u'Gütesiegel', None),
+ (u'Webauskunft', None),
+ (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
+ (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ (u'In Übersichtskarte', True),
+ (u'Forumid', 72)])
+ sledrun = v.to_python(other)
+ assert sledrun.forum_id == 72
+ other2 = v.from_python(sledrun)
+ assert other == other2
+
+ def test_RodelbahnboxValidator(self):
+ v = wrpylib.wrmwmarkup.RodelbahnboxValidator()
+ wikitext = textwrap.dedent(u'''\
+ {{Rodelbahnbox
+ | Position = 47.309820 N 9.986508 E
+ | Position oben =
+ | Höhe oben = 1244
+ | Position unten =
+ | Höhe unten = 806
+ | Länge = 5045
+ | Schwierigkeit =
+ | Lawinen = gelegentlich
+ | Betreiber =
+ | Öffentliche Anreise = Ja
+ | Aufstieg möglich = Nein
+ | Aufstieg getrennt = Nein
+ | Gehzeit = 105
+ | Aufstiegshilfe = Nein
+ | Beleuchtungsanlage = Nein
+ | Beleuchtungstage =
+ | Rodelverleih = Ja
+ | Gütesiegel =
+ | Webauskunft =
+ | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
+ | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
+ | In Übersichtskarte = Ja
+ | Forumid = 72
+ }}''')
+ sledrun = v.to_python(wikitext)
+ wikitext2 = v.from_python(sledrun)
+ assert wikitext == wikitext2
+ wikitext = textwrap.dedent(u'''\
+ {{Rodelbahnbox
+ | Position =
+ | Position oben =
+ | Höhe oben =
+ | Position unten =
+ | Höhe unten =
+ | Länge =
+ | Schwierigkeit =
+ | Lawinen =
+ | Betreiber =
+ | Öffentliche Anreise =
+ | Aufstieg möglich =
+ | Aufstieg getrennt =
+ | Gehzeit =
+ | Aufstiegshilfe =
+ | Beleuchtungsanlage =
+ | Beleuchtungstage =
+ | Rodelverleih =
+ | Gütesiegel =
+ | Webauskunft =
+ | Telefonauskunft =
+ | Bild =
+ | In Übersichtskarte =
+ | Forumid =
+ }}''')
+ sledrun = v.to_python(wikitext)
+ wikitext2 = v.from_python(sledrun)
+ assert wikitext == wikitext2
-def test_RodelbahnboxValidator():
- v = wrpylib.wrmwmarkup.RodelbahnboxValidator()
- wikitext = textwrap.dedent(u'''\
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Aufstieg möglich = Nein
- | Aufstieg getrennt = Nein
- | Gehzeit = 105
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}''')
- sledrun = v.to_python(wikitext)
- wikitext2 = v.from_python(sledrun)
- assert wikitext == wikitext2
- wikitext = textwrap.dedent(u'''\
- {{Rodelbahnbox
- | Position =
- | Position oben =
- | Höhe oben =
- | Position unten =
- | Höhe unten =
- | Länge =
- | Schwierigkeit =
- | Lawinen =
- | Betreiber =
- | Öffentliche Anreise =
- | Aufstieg möglich =
- | Aufstieg getrennt =
- | Gehzeit =
- | Aufstiegshilfe =
- | Beleuchtungsanlage =
- | Beleuchtungstage =
- | Rodelverleih =
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft =
- | Bild =
- | In Übersichtskarte =
- | Forumid =
- }}''')
- sledrun = v.to_python(wikitext)
- wikitext2 = v.from_python(sledrun)
- assert wikitext == wikitext2
+ def test_gasthausbox_to_inn(self):
+ wikitext = u'''{{Gasthausbox
+ | Position = 47.295549 N 9.986970 E
+ | Höhe = 1250
+ | Betreiber =
+ | Sitzplätze =
+ | Übernachtung =
+ | Rauchfrei = Nein
+ | Rodelverleih =
+ | Handyempfang = A1; T-Mobile/Telering
+ | Homepage = http://www.bergkristallhuette.com/
+ | E-Mail = bergkristallhuette@gmx.at
+ | Telefon = +43-664-1808482
+ | Bild = Bergkritsallhütte 2009-02-07.JPG
+ | Rodelbahnen = [[Bergkristallhütte]]
+ }}
+ Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
+ start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
+ wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
-def test_gasthausbox_to_inn():
- wikitext = u'''{{Gasthausbox
- | Position = 47.295549 N 9.986970 E
- | Höhe = 1250
- | Betreiber =
- | Sitzplätze =
- | Übernachtung =
- | Rauchfrei = Nein
- | Rodelverleih =
- | Handyempfang = A1; T-Mobile/Telering
- | Homepage = http://www.bergkristallhuette.com/
- | E-Mail = bergkristallhuette@gmx.at
- | Telefon = +43-664-1808482
- | Bild = Bergkritsallhütte 2009-02-07.JPG
- | Rodelbahnen = [[Bergkristallhütte]]
- }}
- Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
- start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
- wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
+ def test_GasthausboxDictConverter(self):
+ v = wrpylib.wrmwmarkup.GasthausboxDictConverter()
+ other = collections.OrderedDict([
+ (u'Position', (47.295549, 9.986970)),
+ (u'Höhe', 1250),
+ (u'Betreiber', None),
+ (u'Sitzplätze', None),
+ (u'Übernachtung', (None, None)),
+ (u'Rauchfrei', (True, False)),
+ (u'Rodelverleih', (None, None)),
+ (u'Handyempfang', u'A1; T-Mobile/Telering'),
+ (u'Homepage', u'http://www.bergkristallhuette.com/'),
+ (u'E-Mail', u'bergkristallhuette@gmx.at'),
+ (u'Telefon', u'+43-664-1808482'),
+ (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
+ (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
+ inn = v.to_python(other)
+ assert inn.homepage == u'http://www.bergkristallhuette.com/'
+ other2 = v.from_python(inn)
+ assert other == other2
-def test_GasthausboxDictConverter():
- v = wrpylib.wrmwmarkup.GasthausboxDictConverter()
- other = collections.OrderedDict([
- (u'Position', (47.295549, 9.986970)),
- (u'Höhe', 1250),
- (u'Betreiber', None),
- (u'Sitzplätze', None),
- (u'Übernachtung', (None, None)),
- (u'Rauchfrei', (True, False)),
- (u'Rodelverleih', (None, None)),
- (u'Handyempfang', u'A1; T-Mobile/Telering'),
- (u'Homepage', u'http://www.bergkristallhuette.com/'),
- (u'E-Mail', u'bergkristallhuette@gmx.at'),
- (u'Telefon', u'+43-664-1808482'),
- (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
- (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
- inn = v.to_python(other)
- assert inn.homepage == u'http://www.bergkristallhuette.com/'
- other2 = v.from_python(inn)
- assert other == other2
+ def test_GasthausboxValidator(self):
+ v = wrpylib.wrmwmarkup.GasthausboxValidator()
+ wikitext = textwrap.dedent(u'''\
+ {{Gasthausbox
+ | Position = 47.295549 N 9.986970 E
+ | Höhe = 1250
+ | Betreiber =
+ | Sitzplätze =
+ | Übernachtung =
+ | Rauchfrei = Nein
+ | Rodelverleih =
+ | Handyempfang = A1; T-Mobile/Telering
+ | Homepage = http://www.bergkristallhuette.com/
+ | E-Mail = bergkristallhuette@gmx.at
+ | Telefon = +43-664-1808482
+ | Bild = Bergkritsallhütte 2009-02-07.JPG
+ | Rodelbahnen = [[Bergkristallhütte]]
+ }}''')
+ inn = v.to_python(wikitext)
+ wikitext2 = v.from_python(inn)
+ assert wikitext == wikitext2
-def test_GasthausboxValidator():
- v = wrpylib.wrmwmarkup.GasthausboxValidator()
- wikitext = textwrap.dedent(u'''\
- {{Gasthausbox
- | Position = 47.295549 N 9.986970 E
- | Höhe = 1250
- | Betreiber =
- | Sitzplätze =
- | Übernachtung =
- | Rauchfrei = Nein
- | Rodelverleih =
- | Handyempfang = A1; T-Mobile/Telering
- | Homepage = http://www.bergkristallhuette.com/
- | E-Mail = bergkristallhuette@gmx.at
- | Telefon = +43-664-1808482
- | Bild = Bergkritsallhütte 2009-02-07.JPG
- | Rodelbahnen = [[Bergkristallhütte]]
- }}''')
- inn = v.to_python(wikitext)
- wikitext2 = v.from_python(inn)
- assert wikitext == wikitext2
+ def test_googlemap_to_wrmap(self):
+ wikitext = u'''
+ <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
+ (Parkplatz)47.114958,11.266026
+ Erster Parkplatz
-def test_googlemap_to_wrmap():
- wikitext = u'''
- <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
- (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
- </googlemap>
- '''
- attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
- json = wrpylib.wrmwmarkup.googlemap_to_wrmap(attributes, coords, paths)
- assert json['properties']['lon'] == 11.272337
- assert json['properties']['lat'] == 47.113291
- assert json['properties']['zoom'] == 15
- assert json['properties']['height'] == 450
- assert json['features'][0]['properties']['type'] == 'parkplatz'
- assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
- assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
- assert json['features'][1]['properties']['type'] == 'gasthaus'
- assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
- assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
- assert json['features'][2]['properties']['type'] == 'rodelbahn'
- assert json['features'][2]['geometry']['coordinates'] == [
- [11.266262, 47.114715],
- [11.268381, 47.114135],
- [11.269322, 47.113421],
- [11.269979, 47.11277],
- [11.271119, 47.112408]]
+ (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
+ </googlemap>
+ '''
+ attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
+ json = wrpylib.wrmwmarkup.googlemap_to_wrmap(attributes, coords, paths)
+ assert json['properties']['lon'] == 11.272337
+ assert json['properties']['lat'] == 47.113291
+ assert json['properties']['zoom'] == 15
+ assert json['properties']['height'] == 450
+ assert json['features'][0]['properties']['type'] == 'parkplatz'
+ assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
+ assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
+ assert json['features'][1]['properties']['type'] == 'gasthaus'
+ assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
+ assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
+ assert json['features'][2]['properties']['type'] == 'rodelbahn'
+ assert json['features'][2]['geometry']['coordinates'] == [
+ [11.266262, 47.114715],
+ [11.268381, 47.114135],
+ [11.269322, 47.113421],
+ [11.269979, 47.11277],
+ [11.271119, 47.112408]]
-def test_parse_wrmap():
- wikitext = u'''
- <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
- <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
- <parkplatz>47.245789 11.238971</parkplatz>
- <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
- <rodelbahn>
- 47.238587 11.203360
- 47.244951 11.230868
- 47.245470 11.237853
- </rodelbahn>
- </wrmap>
- '''
- json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
- assert json['properties']['lon'] == 11.21408895
- assert json['properties']['lat'] == 47.2417134
- assert json['properties']['zoom'] == 14
- assert json['properties']['width'] == 700
- assert json['properties']['height'] == 400
- assert json['features'][0]['properties']['type'] == 'gasthaus'
- assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
- assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
- assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
- assert json['features'][1]['properties']['type'] == 'parkplatz'
- assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
- assert json['features'][2]['properties']['type'] == 'haltestelle'
- assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
- assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
- assert json['features'][3]['properties']['type'] == 'rodelbahn'
- assert json['features'][3]['geometry']['coordinates'] == [
- [11.203360, 47.238587],
- [11.230868, 47.244951],
- [11.237853, 47.245470]]
+ def test_parse_wrmap(self):
+ wikitext = u'''
+ <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
+ <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
+ <parkplatz>47.245789 11.238971</parkplatz>
+ <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
+ <rodelbahn>
+ 47.238587 11.203360
+ 47.244951 11.230868
+ 47.245470 11.237853
+ </rodelbahn>
+ </wrmap>
+ '''
+ json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
+ assert json['properties']['lon'] == 11.21408895
+ assert json['properties']['lat'] == 47.2417134
+ assert json['properties']['zoom'] == 14
+ assert json['properties']['width'] == 700
+ assert json['properties']['height'] == 400
+ assert json['features'][0]['properties']['type'] == 'gasthaus'
+ assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
+ assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
+ assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
+ assert json['features'][1]['properties']['type'] == 'parkplatz'
+ assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
+ assert json['features'][2]['properties']['type'] == 'haltestelle'
+ assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
+ assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
+ assert json['features'][3]['properties']['type'] == 'rodelbahn'
+ assert json['features'][3]['geometry']['coordinates'] == [
+ [11.203360, 47.238587],
+ [11.230868, 47.244951],
+ [11.237853, 47.245470]]
-def test_create_wrmap():
- geojson = {
- 'type': 'FeatureCollection',
- 'features':
- [{
- 'type': 'Feature',
- 'geometry': {
- 'type': 'Point',
- 'coordinates': [11.190454, 47.240689]},
- 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
- }, {
- 'type': 'Feature',
- 'geometry': {
- 'type': 'Point',
- 'coordinates': [11.238971, 47.245789]},
- 'properties': {'type': 'parkplatz'}
- }, {
- 'type': 'Feature',
- 'geometry': {
- 'type': 'Point',
- 'coordinates': [11.238283, 47.245711]},
- 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
- }, {
- 'type': 'Feature',
- 'geometry': {
- 'type': 'LineString',
- 'coordinates': [
- [11.203360, 47.238587],
- [11.230868, 47.244951],
- [11.237853, 47.245470]]},
- 'properties': {'type': 'rodelbahn'}
- }],
- 'properties': {
- 'lon': 11.21408895,
- 'lat': 47.2417134,
- 'zoom': 14,
- 'width': 700,
- 'height': 400}
- }
+ def test_create_wrmap(self):
+ geojson = {
+ 'type': 'FeatureCollection',
+ 'features':
+ [{
+ 'type': 'Feature',
+ 'geometry': {
+ 'type': 'Point',
+ 'coordinates': [11.190454, 47.240689]},
+ 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
+ }, {
+ 'type': 'Feature',
+ 'geometry': {
+ 'type': 'Point',
+ 'coordinates': [11.238971, 47.245789]},
+ 'properties': {'type': 'parkplatz'}
+ }, {
+ 'type': 'Feature',
+ 'geometry': {
+ 'type': 'Point',
+ 'coordinates': [11.238283, 47.245711]},
+ 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
+ }, {
+ 'type': 'Feature',
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [
+ [11.203360, 47.238587],
+ [11.230868, 47.244951],
+ [11.237853, 47.245470]]},
+ 'properties': {'type': 'rodelbahn'}
+ }],
+ 'properties': {
+ 'lon': 11.21408895,
+ 'lat': 47.2417134,
+ 'zoom': 14,
+ 'width': 700,
+ 'height': 400}
+ }
- wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
- assert wikitext == textwrap.dedent(u'''\
- <wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
+ wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
+ assert wikitext == textwrap.dedent(u'''\
+ <wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
- <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
- <parkplatz>47.245789 N 11.238971 E</parkplatz>
- <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
+ <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
+ <parkplatz>47.245789 N 11.238971 E</parkplatz>
+ <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
- <rodelbahn>
- 47.238587 N 11.203360 E
- 47.244951 N 11.230868 E
- 47.245470 N 11.237853 E
- </rodelbahn>
+ <rodelbahn>
+ 47.238587 N 11.203360 E
+ 47.244951 N 11.230868 E
+ 47.245470 N 11.237853 E
+ </rodelbahn>
- </wrmap>''')
+ </wrmap>''')
import collections
import wrpylib.wrvalidators
import formencode
+import unittest
-def test_OrderedSchema():
- v = wrpylib.wrvalidators.OrderedSchema()
- v.pre_validators = [formencode.Validator()]
- v.chained_validators = [formencode.Validator()]
- v.add_field(u'c', formencode.Validator())
- v.add_field(u'b', formencode.Validator())
- v.add_field(u'a', formencode.Validator())
- v.add_field(u'd', formencode.Validator())
- other = collections.OrderedDict([('d', 'd'), ('b', 'b'), ('a', 'a'), ('c', 'c')])
- python = v.to_python(other)
- assert python.keys() == other.keys()
- assert python.values() == other.values()
- other2 = v.from_python(python)
- assert other.keys() == other2.keys()
- assert other.values() == other2.values()
+class TestWrValidators(unittest.TestCase):
+ def test_OrderedSchema(self):
+ v = wrpylib.wrvalidators.OrderedSchema()
+ v.pre_validators = [formencode.Validator()]
+ v.chained_validators = [formencode.Validator()]
+ v.add_field(u'c', formencode.Validator())
+ v.add_field(u'b', formencode.Validator())
+ v.add_field(u'a', formencode.Validator())
+ v.add_field(u'd', formencode.Validator())
+ other = collections.OrderedDict([('d', 'd'), ('b', 'b'), ('a', 'a'), ('c', 'c')])
+ python = v.to_python(other)
+ assert python.keys() == other.keys()
+ assert python.values() == other.values()
+ other2 = v.from_python(python)
+ assert other.keys() == other2.keys()
+ assert other.values() == other2.values()
-def test_NoneValidator():
- v = wrpylib.wrvalidators.NoneValidator(wrpylib.wrvalidators.Unicode())
- assert v.to_python(u'') == None
- assert v.from_python(None) == u''
+ def test_NoneValidator(self):
+ v = wrpylib.wrvalidators.NoneValidator(wrpylib.wrvalidators.Unicode())
+ assert v.to_python(u'') == None
+ assert v.from_python(None) == u''
-# test_NeinValidator
+ # test_NeinValidator
-# test_Unicode
+ # test_Unicode
-# test_UnicodeNone
+ # test_UnicodeNone
-# test_Unsigned
+ # test_Unsigned
-def test_UnsignedNone():
- v = wrpylib.wrvalidators.UnsignedNone()
- assert v.to_python(u'42') == 42
- assert v.to_python(u'') == None
- assert v.from_python(42) == u'42'
- assert v.from_python(None) == u''
+ def test_UnsignedNone(self):
+ v = wrpylib.wrvalidators.UnsignedNone()
+ assert v.to_python(u'42') == 42
+ assert v.to_python(u'') == None
+ assert v.from_python(42) == u'42'
+ assert v.from_python(None) == u''
-# test_UnsignedNeinNone
+ # test_UnsignedNeinNone
-# test_Loop
+ # test_Loop
-# test_DictValidator
+ # test_DictValidator
-# test_GermanBoolNone
+ # test_GermanBoolNone
-def test_GermanTristateTuple():
- v = wrpylib.wrvalidators.GermanTristateTuple()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Ja') == (True, False)
- assert v.to_python(u'Nein') == (False, True)
- assert v.to_python(u'Teilweise') == (True, True)
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, True)) == u'Nein'
- assert v.from_python((True, False)) == u'Ja'
- assert v.from_python((True, True)) == u'Teilweise'
+ def test_GermanTristateTuple(self):
+ v = wrpylib.wrvalidators.GermanTristateTuple()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Ja') == (True, False)
+ assert v.to_python(u'Nein') == (False, True)
+ assert v.to_python(u'Teilweise') == (True, True)
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, True)) == u'Nein'
+ assert v.from_python((True, False)) == u'Ja'
+ assert v.from_python((True, True)) == u'Teilweise'
-def test_GermanTristateFloat():
- v = wrpylib.wrvalidators.GermanTristateFloat()
- assert v.to_python(u'') == None
- assert v.to_python(u'Ja') == 1.0
- assert v.to_python(u'Nein') == 0.0
- assert v.to_python(u'Teilweise') == 0.5
- assert v.from_python(None) == u''
- assert v.from_python(0.0) == u'Nein'
- assert v.from_python(1.0) == u'Ja'
- assert v.from_python(0.5) == u'Teilweise'
+ def test_GermanTristateFloat(self):
+ v = wrpylib.wrvalidators.GermanTristateFloat()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Ja') == 1.0
+ assert v.to_python(u'Nein') == 0.0
+ assert v.to_python(u'Teilweise') == 0.5
+ assert v.from_python(None) == u''
+ assert v.from_python(0.0) == u'Nein'
+ assert v.from_python(1.0) == u'Ja'
+ assert v.from_python(0.5) == u'Teilweise'
-# test_ValueComment
+ # test_ValueComment
-# test_SemicolonList
+ # test_SemicolonList
-def test_ValueCommentList():
- v = wrpylib.wrvalidators.ValueCommentList()
- assert v.to_python(u'abc') == [(u'abc', None)]
- assert v.to_python(u'abc def') == [(u'abc def', None)]
- assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
- assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
- assert v.to_python(u'value1 (comment); value2') == [(u'value1', u'comment'), (u'value2', None)]
- assert v.to_python(u'value1 (comment1); value2; value3 (comment3)') == [(u'value1', u'comment1'), (u'value2', None), ('value3', 'comment3')]
- assert v.to_python(u'value1 (comment1); [[link (linkcomment)]] (not easy)') == [(u'value1', u'comment1'), (u'[[link (linkcomment)]]', u'not easy')]
+ def test_ValueCommentList(self):
+ v = wrpylib.wrvalidators.ValueCommentList()
+ assert v.to_python(u'abc') == [(u'abc', None)]
+ assert v.to_python(u'abc def') == [(u'abc def', None)]
+ assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
+ assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
+ assert v.to_python(u'value1 (comment); value2') == [(u'value1', u'comment'), (u'value2', None)]
+ assert v.to_python(u'value1 (comment1); value2; value3 (comment3)') == [(u'value1', u'comment1'), (u'value2', None), ('value3', 'comment3')]
+ assert v.to_python(u'value1 (comment1); [[link (linkcomment)]] (not easy)') == [(u'value1', u'comment1'), (u'[[link (linkcomment)]]', u'not easy')]
-# test_GenericDateTime
+ # test_GenericDateTime
-# test_DateTimeNoSec
+ # test_DateTimeNoSec
-# test_DateNone
+ # test_DateNone
-# test_Geo
+ # test_Geo
-def test_GeoNone():
- coord = u'47.076207 N 11.453553 E'
- v = wrpylib.wrvalidators.GeoNone()
- (lat, lon) = v.to_python(coord)
- assert lat == 47.076207
- assert lon == 11.453553
- assert v.to_python(u'') == (None, None)
+ def test_GeoNone(self):
+ coord = u'47.076207 N 11.453553 E'
+ v = wrpylib.wrvalidators.GeoNone()
+ (lat, lon) = v.to_python(coord)
+ assert lat == 47.076207
+ assert lon == 11.453553
+ assert v.to_python(u'') == (None, None)
- assert v.from_python((lat, lon)) == coord
- assert v.from_python((None, None)) == u''
+ assert v.from_python((lat, lon)) == coord
+ assert v.from_python((None, None)) == u''
-# test_MultiGeo
+ # test_MultiGeo
-# test_AustrianPhoneNumber
+ # test_AustrianPhoneNumber
-# test_AustrianPhoneNumberNone
+ # test_AustrianPhoneNumberNone
-# test_AustrianPhoneNumberCommentLoop
+ # test_AustrianPhoneNumberCommentLoop
-# test_GermanDifficulty
+ # test_GermanDifficulty
-# test_GermanAvalanches
+ # test_GermanAvalanches
-def test_GermanPublicTransport():
- v = wrpylib.wrvalidators.GermanPublicTransport()
- assert v.to_python(u'') is None
- assert v.to_python(u'Sehr gut') == 1
- assert v.to_python(u'Gut') == 2
- assert v.to_python(u'Mittelmäßig') == 3
- assert v.to_python(u'Schlecht') == 4
- assert v.to_python(u'Nein') == 5
- assert v.to_python(u'Ja') == 6
+ def test_GermanPublicTransport(self):
+ v = wrpylib.wrvalidators.GermanPublicTransport()
+ assert v.to_python(u'') is None
+ assert v.to_python(u'Sehr gut') == 1
+ assert v.to_python(u'Gut') == 2
+ assert v.to_python(u'Mittelmäßig') == 3
+ assert v.to_python(u'Schlecht') == 4
+ assert v.to_python(u'Nein') == 5
+ assert v.to_python(u'Ja') == 6
- assert v.from_python(None) == u''
- assert v.from_python(1) == u'Sehr gut'
- assert v.from_python(2) == u'Gut'
- assert v.from_python(3) == u'Mittelmäßig'
- assert v.from_python(4) == u'Schlecht'
- assert v.from_python(5) == u'Nein'
- assert v.from_python(6) == u'Ja'
- assert v.from_python(1l) == u'Sehr gut'
+ assert v.from_python(None) == u''
+ assert v.from_python(1) == u'Sehr gut'
+ assert v.from_python(2) == u'Gut'
+ assert v.from_python(3) == u'Mittelmäßig'
+ assert v.from_python(4) == u'Schlecht'
+ assert v.from_python(5) == u'Nein'
+ assert v.from_python(6) == u'Ja'
+ assert v.from_python(1l) == u'Sehr gut'
-# test_GermanTristateFloatComment
+ # test_GermanTristateFloatComment
-# test_UnsignedCommentNone
+ # test_UnsignedCommentNone
-# test_GermanCachet
+ # test_GermanCachet
-# test_url
+ # test_url
-def test_UrlNeinNone():
- v = wrpylib.wrvalidators.UrlNeinNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
+ def test_UrlNeinNone(self):
+ v = wrpylib.wrvalidators.UrlNeinNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Nein') == u'Nein'
+ assert v.to_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'Nein') == u'Nein'
+ assert v.from_python(u'http://www.höttingeralm.at') == u'http://www.höttingeralm.at'
-def test_ValueCommentListNeinLoopNone():
- v = wrpylib.wrvalidators.ValueCommentListNeinLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
+ def test_ValueCommentListNeinLoopNone(self):
+ v = wrpylib.wrvalidators.ValueCommentListNeinLoopNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Nein') == u'Nein'
+ assert v.to_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'Nein') == u'Nein'
+ assert v.from_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
-# test_PhoneNumber
-
+ # test_PhoneNumber
-def test_PhoneCommentListNeinLoopNone():
- v = wrpylib.wrvalidators.PhoneCommentListNeinLoopNone(comments_are_optional=True)
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+ def test_PhoneCommentListNeinLoopNone(self):
+ v = wrpylib.wrvalidators.PhoneCommentListNeinLoopNone(comments_are_optional=True)
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Nein') == u'Nein'
+ assert v.to_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'Nein') == u'Nein'
+ assert v.from_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
-def test_MaskedEmail():
- v = wrpylib.wrvalidators.MaskedEmail()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'abc.def@example.com') == (u'abc.def@example.com', False)
- assert v.to_python(u'abc.def(at)example.com') == (u'abc.def@example.com', True)
- assert v.from_python((None, None)) == u''
- assert v.from_python((u'abc.def@example.com', False)) == u'abc.def@example.com'
- assert v.from_python((u'abc.def@example.com', True)) == u'abc.def(at)example.com'
+ def test_MaskedEmail(self):
+ v = wrpylib.wrvalidators.MaskedEmail()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'abc.def@example.com') == (u'abc.def@example.com', False)
+ assert v.to_python(u'abc.def(at)example.com') == (u'abc.def@example.com', True)
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((u'abc.def@example.com', False)) == u'abc.def@example.com'
+ assert v.from_python((u'abc.def@example.com', True)) == u'abc.def(at)example.com'
-def test_EmailCommentListNeinLoopNone():
- v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'Nein') == u'Nein'
- assert v.to_python(u'first@example.com') == u'first@example.com'
- assert v.to_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
- assert v.from_python(None) == u''
- assert v.from_python(u'Nein') == u'Nein'
- assert v.from_python(u'first@example.com') == u'first@example.com'
- assert v.from_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
- testvalue = u'abc.def(at)example.com (comment)'
- try:
- v.to_python(testvalue)
- assert False
- except formencode.Invalid:
- pass
- try:
- v.from_python(testvalue)
- assert False
- except formencode.Invalid:
- pass
- v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone(allow_masked_email=True)
- assert v.to_python(testvalue) == testvalue
- assert v.from_python(testvalue) == testvalue
-
-
-# test_WikiPage
-
-
-# test_WikiPageList
-
-
-def test_WikiPageListLoopNone():
- v = wrpylib.wrvalidators.WikiPageListLoopNone()
- assert v.to_python(u'') == None
- assert v.to_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
- assert v.from_python(None) == u''
- assert v.from_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
-
-
-# test_TupleSecondValidator
-
-
-def test_BoolUnicodeTupleValidator():
- v = wrpylib.wrvalidators.BoolUnicodeTupleValidator()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'any text') == (True, u'any text')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'any text')) == u'any text'
-
-
-
-
-def test_GermanLift():
- v = wrpylib.wrvalidators.GermanLift()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'Sessellift (4 Euro)') == (True, u'Sessellift (4 Euro)')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'Sessellift (4 Euro)')) == u'Sessellift (4 Euro)'
-
-
-def test_SledRental():
- v = wrpylib.wrvalidators.SledRental()
- assert v.to_python(u'') == (None, None)
- assert v.to_python(u'Nein') == (False, None)
- assert v.to_python(u'Ja') == (True, u'Ja')
- assert v.to_python(u'Talstation (nur mit Ticket); Schneealm') == (True, u'Talstation (nur mit Ticket); Schneealm')
- assert v.from_python((None, None)) == u''
- assert v.from_python((False, None)) == u'Nein'
- assert v.from_python((True, u'Talstation (nur mit Ticket); Schneealm')) == u'Talstation (nur mit Ticket); Schneealm'
- assert v.from_python((True, u'Ja')) == u'Ja'
-
-
-def test_RodelbahnboxDictValidator():
- v = wrpylib.wrvalidators.RodelbahnboxDictValidator()
- other = collections.OrderedDict([
- (u'Position', u'47.309820 N 9.986508 E'),
- (u'Position oben', u''),
- (u'Höhe oben', u'1244'),
- (u'Position unten', u''),
- (u'Höhe unten', u'806'),
- (u'Länge', u'5045'),
- (u'Schwierigkeit', u''),
- (u'Lawinen', u'gelegentlich'),
- (u'Betreiber', u''),
- (u'Öffentliche Anreise', u'Ja'),
- (u'Aufstieg möglich', u'Ja'),
- (u'Aufstieg getrennt', u'Nein'),
- (u'Gehzeit', u'105'),
- (u'Aufstiegshilfe', u'Nein'),
- (u'Beleuchtungsanlage', u'Nein'),
- (u'Beleuchtungstage', u''),
- (u'Rodelverleih', u'Ja'),
- (u'Gütesiegel', u''),
- (u'Webauskunft', u''),
- (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
- (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
- (u'In Übersichtskarte', u'Ja'),
- (u'Forumid', u'72')])
- python = v.to_python(other, None)
- other2 = v.from_python(python, None)
- assert other == other2
-
-
-def test_GasthausboxDictValidator():
- v = wrpylib.wrvalidators.GasthausboxDictValidator()
- other = collections.OrderedDict([
- (u'Position', u'47.295549 N 9.986970 E'),
- (u'Höhe', u'1250'),
- (u'Betreiber', u''),
- (u'Sitzplätze', u''),
- (u'Übernachtung', u''),
- (u'Rauchfrei', u'Nein'),
- (u'Rodelverleih', u''),
- (u'Handyempfang', u'A1; T-Mobile/Telering'),
- (u'Homepage', u'http://www.bergkristallhuette.com/'),
- (u'E-Mail', u'bergkristallhuette@gmx.at'),
- (u'Telefon', u'+43-664-1808482'),
- (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
- (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
- python = v.to_python(other, None)
- other2 = v.from_python(python, None)
- assert other == other2
+ def test_EmailCommentListNeinLoopNone(self):
+ v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Nein') == u'Nein'
+ assert v.to_python(u'first@example.com') == u'first@example.com'
+ assert v.to_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'Nein') == u'Nein'
+ assert v.from_python(u'first@example.com') == u'first@example.com'
+ assert v.from_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
+ testvalue = u'abc.def(at)example.com (comment)'
+ try:
+ v.to_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ try:
+ v.from_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone(allow_masked_email=True)
+ assert v.to_python(testvalue) == testvalue
+ assert v.from_python(testvalue) == testvalue
+
+
+ # test_WikiPage
+
+
+ # test_WikiPageList
+
+
+ def test_WikiPageListLoopNone(self):
+ v = wrpylib.wrvalidators.WikiPageListLoopNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+
+
+ # test_TupleSecondValidator
+
+
+ def test_BoolUnicodeTupleValidator(self):
+ v = wrpylib.wrvalidators.BoolUnicodeTupleValidator()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'any text') == (True, u'any text')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'any text')) == u'any text'
+
+
+
+
+ def test_GermanLift(self):
+ v = wrpylib.wrvalidators.GermanLift()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'Sessellift (4 Euro)') == (True, u'Sessellift (4 Euro)')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'Sessellift (4 Euro)')) == u'Sessellift (4 Euro)'
+
+
+ def test_SledRental(self):
+ v = wrpylib.wrvalidators.SledRental()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'Ja') == (True, u'Ja')
+ assert v.to_python(u'Talstation (nur mit Ticket); Schneealm') == (True, u'Talstation (nur mit Ticket); Schneealm')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'Talstation (nur mit Ticket); Schneealm')) == u'Talstation (nur mit Ticket); Schneealm'
+ assert v.from_python((True, u'Ja')) == u'Ja'
+
+
+ def test_RodelbahnboxDictValidator(self):
+ v = wrpylib.wrvalidators.RodelbahnboxDictValidator()
+ other = collections.OrderedDict([
+ (u'Position', u'47.309820 N 9.986508 E'),
+ (u'Position oben', u''),
+ (u'Höhe oben', u'1244'),
+ (u'Position unten', u''),
+ (u'Höhe unten', u'806'),
+ (u'Länge', u'5045'),
+ (u'Schwierigkeit', u''),
+ (u'Lawinen', u'gelegentlich'),
+ (u'Betreiber', u''),
+ (u'Öffentliche Anreise', u'Ja'),
+ (u'Aufstieg möglich', u'Ja'),
+ (u'Aufstieg getrennt', u'Nein'),
+ (u'Gehzeit', u'105'),
+ (u'Aufstiegshilfe', u'Nein'),
+ (u'Beleuchtungsanlage', u'Nein'),
+ (u'Beleuchtungstage', u''),
+ (u'Rodelverleih', u'Ja'),
+ (u'Gütesiegel', u''),
+ (u'Webauskunft', u''),
+ (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
+ (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ (u'In Übersichtskarte', u'Ja'),
+ (u'Forumid', u'72')])
+ python = v.to_python(other, None)
+ other2 = v.from_python(python, None)
+ assert other == other2
+
+
+ def test_GasthausboxDictValidator(self):
+ v = wrpylib.wrvalidators.GasthausboxDictValidator()
+ other = collections.OrderedDict([
+ (u'Position', u'47.295549 N 9.986970 E'),
+ (u'Höhe', u'1250'),
+ (u'Betreiber', u''),
+ (u'Sitzplätze', u''),
+ (u'Übernachtung', u''),
+ (u'Rauchfrei', u'Nein'),
+ (u'Rodelverleih', u''),
+ (u'Handyempfang', u'A1; T-Mobile/Telering'),
+ (u'Homepage', u'http://www.bergkristallhuette.com/'),
+ (u'E-Mail', u'bergkristallhuette@gmx.at'),
+ (u'Telefon', u'+43-664-1808482'),
+ (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
+ (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
+ python = v.to_python(other, None)
+ other2 = v.from_python(python, None)
+ assert other == other2